Next: Tokens for Words, Previous: Defining Words, Up: Words
The interpretation semantics of a (named) word are what the text
interpreter does when it encounters the word in interpret state. It also
appears in some other contexts, e.g., the execution token returned by
'
word identifies the interpretation semantics of word
(in other words, '
word execute
is equivalent to
interpret-state text interpretation of word).
The compilation semantics of a (named) word are what the text
interpreter does when it encounters the word in compile state. It also
appears in other contexts, e.g, POSTPONE
word
compiles1 the compilation semantics of word.
The standard also talks about execution semantics. They are used
only for defining the interpretation and compilation semantics of many
words. By default, the interpretation semantics of a word are to
execute
its execution semantics, and the compilation semantics of
a word are to compile,
its execution semantics.2
Unnamed words (see Anonymous Definitions) cannot be encountered by
the text interpreter, ticked, or postpone
d, so they have no
interpretation or compilation semantics. Their behaviour is represented
by their XT (see Tokens for Words), and we call it execution
semantics, too.
You can change the semantics of the most-recently defined word:
immediate
– core “immediate”
Make the compilation semantics of a word be to execute
the execution semantics.
compile-only
– gforth “compile-only”
Remove the interpretation semantics of a word.
restrict
– gforth “restrict”
A synonym for compile-only
By convention, words with non-default compilation semantics (e.g.,
immediate words) often have names surrounded with brackets (e.g.,
[']
, see Execution token).
Note that ticking ('
) a compile-only word gives an error
(“Interpreting a compile-only word”).