Reading this article with a quarter-century of hindsight is
interesting. hforth attacks the ROMmability problem and
multi-tasking, both of which I do not plan to address myself in Fforth
(but the idea is that anyone can pick it up and modify it as desired).
The more interesting aspects of the article for me are the Section
"Jump Table Interpreter" which discusses the text interpreter design
and optiCOMPILE,; and the Section "Special compilation action for
default compilation semantics", which discusses something similar to
SET-OPTIMIZER.
The text interpreter is implemented through a table of xts (indexed
with STATE and the FIND result) rather than hard-coded. This table
allows modifying/extending the text interpreter by putting in
different xts, and the article talks about that. It's pretty far from
current recognizer proposals, but pointing into that direction.
optiCOMPILE, is semantically equivalent to COMPILE, but implements
optimizations, in particular inlining (the paper also mentions
eliminating CHARS, but inlining should cover that, too).
The "Special compilation action for default compilation semantics"
gives the example:
:NONAME EXECUTE POSTPONE 2LITERAL ;
: 2CONSTANT
CREATE SWAP , , compiles> DOES> DUP @ SWAP CELL+ @ ;
where "compiles>" takes the xt of the :NONAME definition and uses
somehow for performing the compilation semantics. Apparently the
affected words (e.g., those defined with 2CONSTANT) have a flag set,
and when the compilation semantics is performed on such a word, the xt
passed to "compiles>" is called, with the xt of the compiled word on
the stack. Given the description of the text interpreter,
"optiCOMPILE," has to do this check and call the xt; the article also
mentions POSTPONE, so maybe POSTPONE does not achieve this through
"optiCOMPILE,", or maybe the mention just means that POSTPONE calls
"optiCOMPILE,", not COMPILE,.
In more recent concepts (I'll use Gforth as an example here, but
several other systems have similar concepts), there is not difference
between COMPILE, and "optiCOMPILE,". The code in the :NONAME can be
used to compile a 2constant, and is therefore a proper implementation
of COMPILE, for words defined by 2CONSTANT. The Gforth equivalent of
"compiles>" is called SET-OPTIMIZER, in VFX it is called SET-COMPILER.
One observation is still true:
|It is the user's responsibility to match special compilation action
|with the default compilation semantics.
This means that you must not try to use SET-OPTIMIZER to define
non-default compilation semantics. Those who have tried have found
that while it works as intended in many cases, it does the wrong thing
in other cases, and trying to work around that leads to additional
complications.