Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.lang.forth Subject: xts and return addresses (was: "Back & Forth" - Local variables) Date: Thu, 09 Jan 2025 17:43:05 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 48 Message-ID: <2025Jan9.184305@mips.complang.tuwien.ac.at> References: <752c8e210166d00119336309dc35240d36d6f17d@i2pn2.org> <9747ef2be5ee93d6a4f0c89352a38cec72624609@i2pn2.org> Injection-Date: Thu, 09 Jan 2025 19:00:22 +0100 (CET) Injection-Info: dont-email.me; posting-host="26ca2a267844a559410fefd8d7bda046"; logging-data="3647462"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+m/KkE85MAnifO9MgZ87tr" Cancel-Lock: sha1:HFmE0rAH6kE6ZR4KvuHyhoXJ4s0= X-newsreader: xrn 10.11 Bytes: 2657 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/