When searching for a word with NDCS, what XT should be returned?
NDCS means "Non-Default Compilation Semantics". Immediate words (in the normative sense) are NDCS words, but an NDCS word can be not immediate (in the normative sense).
At the moment my position is as follows.
Meaning of xt
If a word is found by search-wordlist
, the returned xt identifies the execution semantics for the word (standard or system-specific), and it is the same xt regardless of STATE.
Ambiguous conditions
An ambiguous condition exists if interpretation semantics for the word are not defined by the standard and xt is executed (by any means).
An ambiguous condition exists if execution semantics for the word are not defined by the standard and xt is executed in compilation state.
Meaning of the code (the top value)
When a word is found, the top value shall be -1
if the word is an ordinary word (i.e., it has default interpretation semantics and default compilation semantics), and it shall be 1
otherwise.
Thus, the top value is 1
if the found word is an NDCS word. This will not have any unexpected effects concerning immediacy due to the mentioned ambiguous conditions.
Edge cases explanation
If interpretation semantics or execution semantics are not defined by the standard, xt identifies the system-specific execution semantics for the word with the following constrain: if this xt is executed in interpretation state, the interpretation semantics for the word (the standard behavior, or system-specific if not defined by the standard) shall be performed.
For words like to
and s"
, for which interpretation semantics are defined, and execution semantics are not defined, the returned xt, when executed, shall perform the corresponding interpretation semantics in interpretation state regardless of implementation details, and it is not allowed to perform this xt in compilation state because the behavior depends on implementation details.
Ignoring an existing word
Probably, it is conceivable if search-wordlist
returns 0
for a word for which interpretation semantics are not defined by the standard — since a standard program cannot execute the returned xt anyway; examples of such words are if
, >r
, etc.
But a more reliable option is to return an xt that simply throws an exception when executed (or perform a more useful system-defined behavior, if any — see A.3.4.3.2 Interpretation semantics).