A word may be 4 to 8 characters long, depending on implementation; Its address identifies code to be executed - distinguishes kinds of words; Its parameters may be absent, numbers, code or characters - they distinguish words of the same kind.
FORTH is an interpretative program, as are all language processors. It uses a scanner to read character string, identify individual words and find them in the dictionary. The FORTH dictionary differs from a conventional symbol table. Each entry specifies code that is to be executed when that word is encountered. Parameters used by this code are also part of the entry.
Certain words construct dictionary entries for the words they precede - they declare their successors. Each such word identifies the code to be executed when its entry is encountered. For example, a : declares the next word to be a definition.
It is helpful to distinguish 3 classes of words: nouns, verbs and definitions. Illustrating each of these may clarify the structure of the dictionary (Fig. 2).
A noun is a word that names storage. The code it specifies causes either an address or a value to be placed on the stack. (This stack is a last-in/first-out store used to hold arguments - keep them in mind.)
3 VECTOR X
Will reserve 3 consecutive cells for X. When X is seen by the scanner the address of the first cell is placed on the stack.
7 CONSTANT N
will assign 1 cell to hold the constant 7. When N is seen 7 will be placed on the stack.
A . declares a verb and points to the parameter part as the code to be executed. Subsequent words will generate instructions and place them in this region.
A : declares a definition and stores the following character string (until the first ;) in the parameter part. The code specified directs the scanner to interpret this string. The words it finds there may in turn be nouns, verbs, or definitions. Definitions may be referenced within a definition (nested) but may not be declared there.
Dictionary entries are distinguished by the code executed when they are seen and the parameters used by that code.
The process of making a dictionary entry and filling the parameter part is core allocation. A noun fills core with data, a verb with code and a definition with a character string. Clearly different entries will require different amounts of core, which complicates the dictionary search. However the variable length of entries poses no real problem.
Just as making dictionary entries uses core, so deleting them releases core for re-use. To avoid awkward gaps in the dictionary - and because it seems the natural thing to do - only the latest entries my be deleted. The dictionary thus provides the user with direct and effective control of the core assigned him.