COMPILE, is the compilation equivalent of
EXECUTE.
In traditional threaded-code implementations, compilation is
performed by
, (comma). This usage is not portable; it
doesn't work for subroutine-threaded, native code, or
relocatable implementations. Use of
COMPILE, is portable.
In most systems it is possible to implement
COMPILE, so
it will generate code that is optimized to the same extent as
code that is generated by the normal compilation process.
However, in some implementations there are two different
"tokens" corresponding to a particular definition name:
the normal "execution token" that is used while interpreting
or with
EXECUTE, and another "compilation token" that
is used while compiling. It is not always possible to obtain
the compilation token from the execution token. In these
implementations,
COMPILE, might not generate code that
is as efficient as normally compiled code.
The intention is that
COMPILE, can be used as follows to write
the classic interpreter/compiler loop:
Thus the interpretation semantics are left undefined, as
COMPILE,
will not be executed during interpretation.