Preamble
Forth, through the few manuals I've read, is often defined in extremely low-level terms, typically in assembly. Defining Forth in this way is extremely counter-intuitive for understanding implementations, and truly only shines for writing assembly-based or other low-level-language based ports of Forth to varying systems/architectures.
This can be seen in the famous JonesForth, where he implements words that are not necessary to implement in assembly for speed, and which blur the line between where the assembly ends and the Forth begins.
Starting Forth is a much better work that explains Forth in a more understandable manner, however, since it is geared towards teaching Forth itself, it is not very concise in the matter of how a Forth interpreter/compiler actually functions, and again blurs the Forth implementation.
Question
What I am truly asking is concisely what is involved in a functioning Forth implementation? What is the high-level model to how Forth works? So far I understand:
- Forth uses a dictionary to look up defined words
- Forth has two stacks, a parameter stack and return stack
- The parameter stack is used to hold values being operated on, whereas the return stack is used to hold return positions from jumps to nested words
- The primitive word NEXT is used to return to the state of the top of the return stack and typically appears after every defined word.
This is all I can truly say for sure because in the ANS FORTH-83 required word set, INTERPRET is not defined, however in Starting Forth, INTERPRET is defined as a primitive word used to check the dictionary for a word, if not check if it's a number, and if not abort. All of this conflicting information, and conversely the lack of information about Forth has overall made the guts of Forth complex to understand.
NEXT
. It's used to perform the action of the next word inside a colon definition. The word that jumps to the address on the top of the return stack isEXIT
. – Lesbosciforth
. Alfred van der Horst has done a wonderful job with a single assembler file for LInux NAtive Forth, LINA. Most of the core forth is assembler, with a block library of all the nicety extensions one would expect for a functional forth. Most of the assembler is written in acolon definition
style, to highlight how each word builds on a tiny nucleus of raw CODE definitions. It's heady, at first, but when you gloss over the assembler details, and start to read the "Forth in the code", it might help in your quest for understanding. – Huston