Next: Tokens for Words, Previous: Defining Words, Up: Words [Contents][Index]
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
compiles18 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.19
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”
Mark the last definition as compile-only; as a result, the text
interpreter and '
will warn when they encounter such 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 a warning
(“<word> is compile-only”).
• Combined words: |
In standard terminology, “appends to the current definition”.
In standard terminology: The default interpretation semantics are its execution semantics; the default compilation semantics are to append its execution semantics to the execution semantics of the current definition.
Next: Tokens for Words, Previous: Defining Words, Up: Words [Contents][Index]