Sujet : Re: "Back & Forth" - Local variables
De : albert (at) *nospam* spenarnc.xs4all.nl
Groupes : comp.lang.forthDate : 10. Jan 2025, 12:10:37
Autres entêtes
Organisation : KPN B.V.
Message-ID : <nnd$016c46aa$07482b03@b0a5d80ab286ace4>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
nnd$44fc771d$089c856c@db10b46852f85b89>,
Hans Bezemer <
the.beez.speaks@gmail.com> wrote:
On 09-01-2025 13:42, dxf wrote:
There is no guarantee that a saved interpreter pointer on the
stack is an execution token.
>
Nope - in ANS-Forth it is listed as:
>
nest-sys; definition calls; implementation dependent
>
So - that's obvious. But in 4tH it works out. And defining it as >R
works out as well. BTW, I've tested the thing - and it holds up.
>
I got my work cut out for a next episode! On co-routines! ;-)
>
Hans Bezemer
>
BTW, I've heard there are implementations where nest-sys aren't even on
the return stack. The standard seems to confirm this:
>
return stack: A stack that _MAY_BE_ used for program execution nesting,
do-loop execution, temporary storage, and other purposes.
>
.. and sorry to spoil the fun, but what we're doing here is illegal anyways:
>
"A program shall _NOT_ access values on the return stack (using R@, R>,
2R@ or 2R>) that it _DID_NOT_ place there using >R or 2>R;"
>
In other words: your mileage may (be) very, very illegal.
The use of CO / ;: can't be illegal. Its implementation may not be
portable, that is another matter.
There is no reference to the return stack in the glossary of CO.
========================
CO
STACKEFFECT:
DESCRIPTION: []
Return to the caller, suspending interpretation of the current
definition, such that when the caller exits, this definition is
resumed. The return stack must not be engaged, such as between >R and
R> , or DO and LOOP .
GLOSSARY INDEX
SEE ALSO: CONTROL EXIT
========================
Merely a warning that the ciforth implementation doesn't work well with
certainly manipulations of the return stack.
The strict forbidden of nested definitions is non-sensical,
I allow nested definitions in ciforth with an extension.
: aap { : add + ; ] 1 2 add 3 4 add * ;
The program is non-standard, but if this extension is loaded the Forth
is still conforming.
>
Hans Bezemer
>
Groetjes Albert
-- Temu exploits Christians: (Disclaimer, only 10 apostles)Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style WallArt For Home, Office And Garden Decor - Perfect For Windows, Bars,And Gifts For Friends Family And Colleagues.