PDA

View Full Version : Max-FORTH equivalent to VOCABULARY?


les@windstream
03-25-02, 09:48 PM
Is there a way to define alternative vocabularies in Max-FORTH? I don't see the standard methods for doing this in the glossary, and wondered if there was an alternative.

Thanks,

rob
03-26-02, 03:38 AM
MaxForth only has one dictionary but it can support alternate mechanisms such as vocabularies. The dictionary is searched by the text interpreter during interpreting or compiling; appended to by the defining words like CREATE : CONSTANT VARIABLE; and edited by FORGET and UNDO. They all assume the same dictionary structure which is a linked list of headers. The first word in the list is the last defined word. If you add a word to the dictionary, it will become the first word in the list and you can see this by typing WORDS (this is also the test word when playing around with dictionary mechanisms usually accompanied with the memory examiner, DUMP). The first word in the list is pointed to by the system variable last. This is the head of the word list. All the words that interact with the dictionary use this variable. You can access this system variable through another system variable, CURRENT (CONTEXT is an alias for CURRENT).

To get the head of the list pointer:

CURRENT @ CONSTANT last ( get the current head of the list

Now you can use last to implement alternate vocabularies.

Rob