Append the execution semantics of the definition represented by xt to the execution semantics of the current definition.
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.
ruv Interpretation semanticsComment2019-06-26 12:50:14
According to "4.1.2 Ambiguous conditions", a standard programme can't obtain the execution token of a definition with undefined interpretation semantics. So, it can't obtain xt of
COMPILE, word by any means (according to the current specification for this word).
And the following code is not standard — without any solid reason:
: foo [ ' DUP COMPILE, ] ;
But the following code is standard:
: bar COMPILE, ; : foo [ ' DUP bar ] ;
COMPILE, should be a regular word with single semantics (the execution semantics). But executing of this word when current definition was not started (by
:, or other similar words if any) should be an ambiguous condition.