Introduction |
|
This introduction does not set out to teach Forth programming but rather to serve as a supplement to available bases on the subject. The sintax consists of Forth words or literals, separated by spaces and terminated by a carriage return. A valid name must non contain any embedded space since this will be interpreted as two distint words, and must be less than 31 character in length. If a word is entered which does not exist or has been spelt wrongly, or the number entered is not valid in the current base, then an error message will be displayed. To compile and execute programs created using the editor type
Throughout these examples e.g. will generate an error message 0 since the word does not exist.
will generate an error message 0 since Other
errors messages include: In order to
program in Forth, it is necessary to define new words based on the
words already in the vocabulary. Values to be passed to these words are pushed
onto the stack and if required, the world will pull these values from the stack,
operate on them and push the result onto the stack for use by another word. As
mentioned previously, Forth uses Reverse Polish Notation and integer numbers,
therfore no precedence of operators is available, thus all operation are
performed in the sequence in which they are found on the stack. e.g. As can be seen, in RPN the operators are input after
the numbers on which they have to operate have been input. We will now discuss
some off the words in greater depth.
|
Ultimo aggiornamento: 10-12-2002. Copyright (c) 2000-2002 Matteo Vitturi.
|