Search code examples
forthgforth

How to list the current set of words in Forth


Is it possible to get the list of all words which are currently defined in Forth (for example in Gforth)?


Solution

  • Standard WORDS word prints all the words from the top vocabulary (wordlist) only — see the specification .

    TRAVERSE-WORDLIST proposal defines API to enumerate words in given wordlist. Some Forth-systems already implemented this proposal ([update] it is already in the draft).

    Although there is no standard API to enumerate all defined wordlists. GET-ORDER gives a list of the context wordlists only (i.e. wordlists in the scope).

    Some Forth-systems have VOCS word that prints all defined vocabularies. Other possible APIs are specific for particular Forth-system. For example, SP-Forth has ENUM-VOCS word to enumerate all known wordlists.