Deutsch   English   Français   Italiano  
<9747ef2be5ee93d6a4f0c89352a38cec72624609@i2pn2.org>

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

Path: ...!weretis.net!feeder9.news.weretis.net!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 22:09:06 +1100
Organization: i2pn2 (i2pn.org)
Message-ID: <9747ef2be5ee93d6a4f0c89352a38cec72624609@i2pn2.org>
References: <nnd$75b7a2a4$616fdd6b@4f60b314ce95c9b9>
 <nnd$0a3352ed$2c40f494@296559c013ec38eb>
 <nnd$65a6d402$1bfbf0ca@d49afc2a32e40cf2>
 <752c8e210166d00119336309dc35240d36d6f17d@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 9 Jan 2025 11:09:05 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="2757964"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="XPw7UV90Iy7EOhY4YuUXhpdoEf5Vz7K+BsxA/Cx8bVc";
User-Agent: Mozilla Thunderbird
X-Spam-Checker-Version: SpamAssassin 4.0.0
In-Reply-To: <752c8e210166d00119336309dc35240d36d6f17d@i2pn2.org>
Content-Language: en-GB
Bytes: 1882
Lines: 50

On 9/01/2025 9:50 am, dxf wrote:
> 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.
> ...

More portable

: (lx) >R ;

: LOCAL R> SWAP DUP >R @ >R (lx) R> R> ! ;

VARIABLE A
VARIABLE B

8 A !
7 B !

: divide ( a b -- )
    A LOCAL
    B LOCAL
    B ! A !  A @ B @ /
    . CR
;

15 3 divide A ? B ?