Some systems (e.g., Gforth-0.7) implement words (e.g., if
) without interpretation semantics;
what should these systems do when the nt of if
is passed to name>interpret
? The standard says that it returns 0.
The standard says "If nt has no interpretation semantics, NAME>INTERPRET
returns 0". This is an unclear formulation, since it's impossible for a Forth system not to have interpretation semantics for a word (see below); and if one means the standard, one should say "interpretation semantics are not defined by this standard".
Anyway, the standard allows to return 0 in this case, but it also allows to return an xt of a system-specific behavior.
If it did not say that, what else should it say for that case?
I think the standard could say that in this case name>interpret
shall return an xt for a system-defined behavior (the system anyway shows some behavior).
An example of wording (based on my proposal 1110):
- xt identifies the execution semantics of the word identified by nt. When this xt is executed in interpretation state, the interpretation semantics for the word are performed.
If interpretation semantics for the word are not defined by this standard, the system-defined interpretation semantics are performed.
An ambiguous condition exists in any of the following conditions:
- interpretation semantics for the word are not defined by this standard and xt is executed;
- execution semantics of the word are not defined by this standard and xt is executed in compilation state;
What does Gforth-0.7 do when its text interpreter encounters if
in interpretation state? This behavior is the implemented interpretation semantics for if
.
And name>interpret
may return an xt that shows this behavior in interpretation state, also it may return [: -14 throw ;]
regardless what behavior is shown.
And no standard program can have any problem due to this behavior of name>interpret
. Right?
but you can use it to detect that the system at hand does not define interpretation semantics.
I would say it does not define an execution token for the word (and for that semantics). Because some interpretation semantics are actually defined by the system anyway (for example, it shows an error message and does abort).
What it does with that information is up to the program; in the text interpreter example above a -14 throw
was performed,
but, e.g., an implementation of find
will probably not do that.
find
in interpretation state may return the same xt that name>interpret
returns.