| I'm no Forth guru, and I'm sure there are others who are much better
qualified than I am to discuss Forth, but here goes anyway :-)
Forth is a threaded-interpreted language where the program developer
manipulates the stack directly. Another feature of the language
is that rather than coding a program using a particular syntax
developed by the language designer, the Forth programmer develops
his own "lexicon" of Forth words. You start with a base level
of words which have been defined by the implementor, and then
go on to build your own words, which eventually get to be a very
high level language. As each word is defined it is compiled
into the dictionary, so that when a word is executed, the
interpreter only needs to follow the pointers to the lowest level
machine code, which it then executes. This allows very fast
execution time, with minimal memory.
Thus a program to run a dishwasher might read something like:
water open
wash
rinse
water close
dry
stop
Of course, this isn't what a real program would look like, but
the idea is that each word (such as "wash", "rinse", etc.) is
composed of words in its' definition, and each of those words
is composed of lower-level words, and so forth, until you get
down to the primitives supplied with the implementation. The
primitives are coded in machine language.
Brodie has recently come out with another book called "Thinking
Forth". It's really excellent, and I recommend it highly, not
just for understanding how Forth works, but for understanding
the philosophy behind Forth.
|