On 2021-06-10 18:49, Anton Ertl wrote:
> Krishna Myneni <
krishna...@ccreweb.org> writes:
>> I notice that the Forth-2012 standard does not indicate that EXECUTE
>> does not specify that something may be placed on the return stack while
>> the xt is being executed. Is an implementation of EXECUTE which pushes
>> and pops nest-sys onto the return stack considered to be standard?
>
> I assume you mean as in: EXECUTE pushes a nest-sys, performs the xt,
> then pops nest-sys.
>
> As Ruvim notes, the standard undefines interpretation semantics for
> words that deal with the return stack, and as a consequence a standard
> program cannot tick or FIND these words.
More neatly, a standard program cannot use "FIND" to obtain the
execution token of such a word.
But it can use "FIND" to obtain xt of a definition that serves to
perform the interpretation or compilation semantics for such a word.
This xt just cannot be considered as an xt that identifies the execution
semantics of the argument of "FIND" (for the words with non default
interpretation semantics).
Certainly, a standard program cannot perform interpretation semantics
for the words with undefined interpretation semantics.
> So can a standard program
> get at the xt of such a word? If not, you can implement EXECUTE in
> such a way.
My conclusion that a standard program cannot get xt of such a word, i.e.
an xt that identifies execution semantics of this word (a word with non
default interpretation semantics).
> The only possible way I see is through NAME>COMPILE. That's not
> guaranteed to produce an xt for performing >R, but if it does, you
> should be able to EXECUTE it.
It seems, you meant "NAME>INTERPRET". But it doesn't return the
execution token that identifies execution semantics for a word in the
argument.
The returned xt "represents the interpretation semantics" for a word in
the argument. It isn't enough precisely formulated. But the idea is that
performing xt performs the interpretation semantics for the word in the
argument.
A problem is that a standard program cannot perform interpretation
semantics for a word with undefined interpretation semantics.
Even via "NAME>INTERPRET", this behavior cannot be tested by a standard
program. It can be any implementation-defined behavior.
For example, the following code is non standard
: ?name>interpret ( nt -- xt )
dup 0= -13 and throw
name>interpret
dup 0= -14 and throw
;
">r" find-name ?name>interpret value interp(>r)
: >r_v2 interp(>r) execute ;
\ The behavior of ">r_v2" cannot be concluded form the standard.
\ And so, it cannot be tested by a standard program.
\ And then, it may show any behavior.
In some plausible system ">r_v2" shows the expected behavior. But in
another plausible system ">r_v2" throws an exception.
> If you can get at the xt, then EXECUTE must not push nest-sys or the
> system must be designed such that it works around these pushes.
It would restrict implementations, but a standard program cannot get
such xt.
--
Ruvim