Proposal: VOCABULARY

Accepted

This proposal has been moved into this section. Its former address was: /standard/search

This page is dedicated to discussing this specific proposal

ContributeContributions

UlrichHoffmannavatar of 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)

GeraldWodniavatar of GeraldWodniNew Version: VOCABULARY

Hide differences

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 , 
     WORDLIST CREATE , 
   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)

AntonErtlavatar of AntonErtl

The committee felt there was no question that this is common practice, so it skipped the CfV part and went directly to committee vote. Vote #7: 12Y:0:0 Accepted

Accepted

nekoavatar of neko

Hello, I noticed this proposal has been accepted for well over 3 years now, and yet the relevant section has not been added. Is this a mistake?

AntonErtlavatar of AntonErtl

The document has not been updated since 2019. I have become the editor some time ago, but I have not gotten around to it.

Moreover, if you mean this website, it reflects the contents of the Forth-2012 document. When the next release (rather than draft) of the standard document happens, this will be updated. There are also ideas of having a way to let it reflect the latest draft, but for now the process from the document to this website requires too much work to make this realistic.

Reply New Version