Deutsch   English   Français   Italiano  
<752c8e210166d00119336309dc35240d36d6f17d@i2pn2.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: dxf <dxforth@gmail.com>
Newsgroups: comp.lang.forth
Subject: Re: "Back & Forth" - Local variables
Date: Thu, 9 Jan 2025 09:50:52 +1100
Organization: i2pn2 (i2pn.org)
Message-ID: <752c8e210166d00119336309dc35240d36d6f17d@i2pn2.org>
References: <nnd$75b7a2a4$616fdd6b@4f60b314ce95c9b9>
 <nnd$0a3352ed$2c40f494@296559c013ec38eb>
 <nnd$65a6d402$1bfbf0ca@d49afc2a32e40cf2>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 8 Jan 2025 22:50:51 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="2677998"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="XPw7UV90Iy7EOhY4YuUXhpdoEf5Vz7K+BsxA/Cx8bVc";
User-Agent: Mozilla Thunderbird
In-Reply-To: <nnd$65a6d402$1bfbf0ca@d49afc2a32e40cf2>
Content-Language: en-GB
X-Spam-Checker-Version: SpamAssassin 4.0.0
Bytes: 1804
Lines: 42

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 .