Node:Interpretation and Compilation Semantics, 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
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,
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
postponed, so they have no
interpretation or compilation semantics. Their behaviour is represented
by their XT (see Tokens for Words), and we call it execution
You can change the semantics of the most-recently defined word:
Make the compilation semantics of a word be to
immediate-- core ``immediate''
executethe execution semantics.
Remove the interpretation semantics of a word.
compile-only-- gforth ``compile-only''
A synonym for
restrict-- gforth ``restrict''
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").
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.