Programming in Forth means adding words to the dictionary. When
adding a new word every word already in the dictionary can be
used by adding it's execution semantics to the execution
semantics of the newly created word.
Programming an application in Forth means building bottom up
a hierarchy of words until a single word or a small set of
application specific words solves the problem.
When Forth is about build a new word it's in compiling
state. The usual way to build a new word and enter compiling
state is using the word
:
('colon')
like this:
: PRINT-SUM + . ;
In this example, the colon parses away the following white-space
delimited token and creates a new definition then named PRINT-SUM.
Then compilation state is entered. From now on each word is not
executed but compiled. This means not the execution semantics is
performed but an alternative compilation semantics.
The compilation semantics of + and . is to add
their respective execution semantics to the word in creation.
The final ;-semicolon
has the compilation semantics to finish compilation of the word
defined by the preceding colon.
The compilation semantics of most words is to add their execution
semantics to the compiled word. There must be some special words
too with other compilation semantics like ;-semicolon in
order to control the compilation.
Now we have new word named PRINT-SUM which has both the
execution semantics of + and .. Instead of the
sequence + .
we can furtheron say PRINT-SUM:
1234 8765 + . 9999 ok
1234 8765 PRINT-SUM 9999 ok
If you started the pfe inside another Operating System, you can
quit the task by typing
bye
.
Using
quit
will reset the current interpreter. If that is not sufficient
try
abort
.