The most common use of the compilation semantics of a word w is
when w is text-interpreted in compile state, the state right after
starting a definition with, e.g., :
.
: hello s" hello" type ;
In this example, the text interpreter performs the compilation
semantics of s"
, type
and ;
(after first
performing the interpretation semantics of :
)
When you postpone a word, you also use the compilation semantics.
: compile-+ ( -- ) \ compiled code: ( n1 n2 -- n ) POSTPONE + ; : foo ( n1 n2 -- n ) [ compile-+ ] ; see foo
Here the POSTPONE +
compiles (rather than performs) the
compilation semantics of +
into compile-+
. In the
definition of foo
, (the interpretation semantics of)
compile-+
is performed, which in turn performs the compilation
semantics of +
, i.e., it compiles +
into foo
.
The compilation semantics is represented by a compilation token
(see Compilation token). You can get the compilation token of a
word w with ``w name>compile
, comp' w
, or
[comp'] w
. The first form first gets the name token of
w and then accesses the compilation token with
name>compile
.