-
Notifications
You must be signed in to change notification settings - Fork 2
Symbols lookup
Forth parse input stream (source code) by selecting non-space characters group as a word name, and then search an executable element in vocabulary by this name, one word in time.To do it we need the lookup method, which able to do such search only in one context vocabulary, or form a chain of contexts where a search will be continued. This contexts chain forms the dynamic scope -- every name will be searched from inner context to the next outer one.
The way how dynamic scope is forming can be selected freely on your own taste. Most modern languages use lexical scoping -- the source code structure will lead scope formation in runtime in a tree-like way: every variable/object name will be searched from inner { } block to outer ones.
The classical Forth prefer only linear search order fully controllable by the programmer in runtime. The most simple Forth system has only one vocabulary in a system, which is the easiest way to lookup: