xts and return addresses (was: "Back & Forth" - Local variables)

Liste des GroupesRevenir à cl forth 
Sujet : xts and return addresses (was: "Back & Forth" - Local variables)
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forth
Date : 09. Jan 2025, 18:43:05
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025Jan9.184305@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5
User-Agent : xrn 10.11
albert@spenarnc.xs4all.nl writes:
R EXECUTE doesn't work for ciforth.
There is no guarantee that a saved interpreter pointer on the
stack is an execution token.

In development Gforth, if you use the xt of a colon definition as a
return address, you get the same effect as EXECUTE.  E.g.

: colon-execute >r ;

1 ' . colon-execute \ prints "1"

I have recently had a puzzling bug syndrome in the following word
(buggy version shown):

: reverse-sections-execute ( xt -- )
    >r sections $@ cell mem-do
        j i @ section-execute
    loop ;

[: current-section @ cr h. ;] reverse-sections-execute

The output is:

$7FF5F428F000
$7FF5F3F1A000
$7FF5F3F3B000
$7FF5E5BFD000
$7FF5E5DFE040
$7FF5F4298000
$7FF5E5DFE040  ok

The last line should not be output.  What happens is that the xt
passed to REVERSE-SECTIONS-EXECUTE is pushed on the return stack, and
I then forgot to drop it.  But instead of that resulting in a crash
(as you would get in Gforth up to around 2020), with the new xt
implementation the ; at the end COLON-EXECUTEs the xt.  And because
the xt is a colon definition, this calls the xt again.

xt=pfa has it's advantages, but here a disadvantage showed up.

- anton
--
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: https://forth-standard.org/
EuroForth 2023 proceedings: http://www.euroforth.org/ef23/papers/
EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

Date Sujet#  Auteur
8 Jan 25 * "Back & Forth" - Local variables39Hans Bezemer
8 Jan 25 +- Re: "Back & Forth" - Local variables1dxf
8 Jan 25 `* Re: "Back & Forth" - Local variables37albert
8 Jan 25  +* Re: "Back & Forth" - Local variables21Hans Bezemer
8 Jan 25  i`* Re: "Back & Forth" - Local variables20albert
8 Jan 25  i +* Re: "Back & Forth" - Local variables2mhx
9 Jan 25  i i`- Re: "Back & Forth" - Local variables1albert
11 Mar 25  i `* Re: "Back & Forth" - Local variables17dxf
11 Mar 25  i  +- Re: "Back & Forth" - Local variables1dxf
11 Mar 25  i  +* Re: "Back & Forth" - Local variables4Hans Bezemer
12 Mar 25  i  i`* Re: "Back & Forth" - Local variables3dxf
12 Mar 25  i  i +- Re: "Back & Forth" - Local variables1albert
13 Mar 25  i  i `- Re: "Back & Forth" - Local variables1dxf
12 Mar 25  i  `* Re: "Back & Forth" - Local variables11dxf
13 Mar 25  i   `* Re: "Back & Forth" - Local variables10sjack
14 Mar 25  i    `* Re: "Back & Forth" - Local variables9dxf
14 Mar 25  i     +* Re: "Back & Forth" - Local variables2sjack
14 Mar 25  i     i`- Re: "Back & Forth" - Local variables1sjack
16 Mar 25  i     `* Re: "Back & Forth" - Local variables6Hans Bezemer
16 Mar 25  i      `* Re: "Back & Forth" - Local variables5sjack
16 Mar 25  i       +- Re: "Back & Forth" - Local variables1sjack
17 Mar 25  i       +- Re: "Back & Forth" - Local variables1sjack
17 Mar 25  i       `* Re: "Back & Forth" - Local variables2sjack
18 Mar 25  i        `- Re: "Back & Forth" - Local variables1dxf
8 Jan 25  +* Re: "Back & Forth" - Local variables13Hans Bezemer
8 Jan 25  i`* Re: "Back & Forth" - Local variables12dxf
9 Jan 25  i `* Re: "Back & Forth" - Local variables11dxf
9 Jan 25  i  +* Re: "Back & Forth" - Local variables9albert
9 Jan 25  i  i+* Re: "Back & Forth" - Local variables7dxf
9 Jan 25  i  ii`* Re: "Back & Forth" - Local variables6Hans Bezemer
10 Jan 25  i  ii +* Re: "Back & Forth" - Local variables4dxf
10 Jan 25  i  ii i+- Re: "Back & Forth" - Local variables1Hans Bezemer
10 Jan 25  i  ii i`* Re: "Back & Forth" - Local variables2sjack
10 Jan 25  i  ii i `- Re: "Back & Forth" - Local variables1dxf
10 Jan 25  i  ii `- Re: "Back & Forth" - Local variables1albert
9 Jan 25  i  i`- xts and return addresses (was: "Back & Forth" - Local variables)1Anton Ertl
9 Jan 25  i  `- Re: "Back & Forth" - Local variables1sjack
10 Jan 25  `* Re: "Back & Forth" - Local variables2albert
10 Jan 25   `- Re: "Back & Forth" - Local variables1Hans Bezemer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal