Proposal: VOCABULARY
This proposal has been moved into this section. Its former address was: /standard/search
This page is dedicated to discussing this specific proposal
ContributeContributions
UlrichHoffmann [117] VOCABULARYProposal2019-09-18 12:32:53
Vocabulary proposal
version uh 2019-09-18
Add the following section to the Forth-200x standard in the optional Search-Order word set to the Search-Order extension word list.
16.6.2.3000 VOCABULARY
( "<spaces>name" -- )
Skip leading space delimiters. Parse name delimited by a space. Create a definition for name with the execution semantics defined below. Create a new empty word list wid and associate it with name.
name is referred to as a "vocabulary".
name Execution:
( -- )
Replace the first word list in the search order by the word list wid that is associated with the vocabulary.
An ambiguous condition exists if there are no word lists in the search order.
See: 16.6.1.2460 WORDLIST 16.6.2.0715 ALSO 16.6.2.2038 PREVIOUS 16.6.1.2195 GET-ORDER 16.6.1.2197 SET-ORDER
Rationale: VOCABULARY has been used in traditional Forth systems and it is available with consistent behaviour in many standard systems. So it seems worthwhile to standardize it (again, it has been standardized in Forth-83).
Typical use:
VOCABULARY Assembler
ONLY FORTH ALSO Assembler DEFINITIONS ( set search order to ... FORTH Assembler Assembler )
Reference Implementation:
: VOCABULARY ( -- )
CREATE WORDLIST ,
DOES> ( -- ) @
>R GET-ORDER SWAP DROP
R> SWAP SET-ORDER ;
Other additions
Add the following ambigous condition to 16.4.1.2:
- executing a vocabulary word when the search order is empty (16.6.2.3000)