Buy GNU books!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
An execution token (XT) represents some behaviour of a word.
You can use
execute to invoke this behaviour.
You can use
' to get an execution token that represents the
interpretation semantics of a named word:
5 ' . execute
' parses at run-time; there is also a word
['] that parses
when it is compiled, and compiles the resulting XT:
: foo ['] . execute ; 5 foo : bar ' execute ; \ by contrast, 5 bar . \ ' parses "." when bar executes
If you want the execution token of word, write
in compiled code and
' word in interpreted code. Gforth's
['] behave somewhat unusually by complaining about
compile-only words (because these words have no interpretation
semantics). You might get what you want by using
[COMP'] word DROP (for details see section 5.11.2 Compilation token).
Another way to get an XT is
(see section 5.9.6 Anonymous Definitions). For anonymous words this gives an xt
for the only behaviour the word has (the execution semantics). For
lastxt produces an XT for the same behaviour it
would produce if the word was defined anonymously.
:noname ." hello" ; execute
An XT occupies one cell and can be manipulated like any other cell.
In ANS Forth the XT is just an abstract data type (i.e., defined by the operations that produce or consume it). For old hands: In Gforth, the XT is implemented as a code field address (CFA).
|webmaster||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|