Re: The IMMEDIATE mess




J Thomas wrote:
GerryJ wrote:

No it doesn't use an extra cell - see my reply to Andreas Kochenburger

Yes, you solved that problem.

The way I imagined you solving it was to provide one execution token
for normal words, and when you make a word special you redirect that,
you provide an execution token that points to two others and let the
interpreter choose which of them to use.

Your solution was to have each word point to a class. The normal words
would presumably all point to a class that did:

When interpreting, calculate the xt based on the return address the
normal word left, and execute it.
When compiling, calculate the xt based on the return address and
compile it.


It's not done that way, the xt (in ANS terms) is the address of the
semantics pointer i.e. the address of the pointer to the semantics
class. The text interpreter passes this xt on the stack to the
interpret() or compile() method so they don't have to calculate it.
This xt provides access to the body of the word. I didn't show the xt
in my example to avoid confusing the issue but the stack signatures
should be ( xt -- ), that is a DROP is required in the example :noname
definitions. In reality they would be consumed usefully.

If by 'normal words' you mean colon definitions, yes they all point to
the same class. Other normal words like variables all point to a
different class as different actions are required i.e. push a dataspace
address instead of executing Forth code.

Gerry

.