Search code examples
forth

Is there a difference between Forth vocabularies and word lists?


As I read "Programming Forth" by Stephen Pelc, the text seems to imply that vocabularies and word lists may be separate things. I have thought that dictionary vocabulary entries have a name field, code field, etc. so having separate word lists does not make sense to me.

Are word lists just a way of talking about the name fields of Forth words or are word lists actual data structures separate from dictionary entries? (Forth language resources are a bit scarce compared to mainstream languages)


Solution

  • Vocabularies and wordlists are basically the same. I can think of two differences:

    • Wordlists are specified in the Forth standard. Vocabularies are not, but there's nearly a consensus on how they are used.
    • A vocabulary has a name. A wordlist just has a numeric id.

    A third similar concept is a "lexicon". I haven't seen it used as often as the other two, but I think it's yet another variation or a synonym.

    A wordlist is a collection of dictionary entries. It could be a linked list, a hash table, or anything else that works for looking up named entries. The dictionary may be partitioned into several wordlists, i.e. a wordlist is a subset of the dictionary.