Sujet : Re: "Back & Forth" - Local variables
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 08. Jan 2025, 23:50:52
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <752c8e210166d00119336309dc35240d36d6f17d@i2pn2.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 9/01/2025 5:11 am, Hans Bezemer wrote:
On 08-01-2025 17:27, albert@spenarnc.xs4all.nl wrote:
( my CO variant, using the return address)
: LOCAL R> SWAP DUP >R @ >R EXECUTE R> R> ! ;
VARIABLE A
VARIABLE B
\ I'm paranoid :)
8 a !
7 b !
: divide
A LOCAL
B LOCAL
B ! A ! A @ B @ /
. CR
;
15 3 divide a ? b ?
\ it doesn't mean they're not out to get you
Wow! This works! Can't say how solid it is.. but still!
Alas not portable.
If I'm playing this game (e.g. a routine needs to be re-entrant) then
I spell out what I'm doing. Nobody gets confused and no surprises.
8 VALUE A
7 VALUE B
: divide
A B 2>R TO B TO A
A B / . CR
2R> TO B TO A
;
15 3 divide a . b .