| Deutsch English Français Italiano |
|
<nnd$24c65e7e$1eb23494@5fa571a46b879ee7> View for Bookmarking (what is this?) Look up another Usenet article |
Newsgroups: comp.lang.forth
References: <nnd$75b7a2a4$616fdd6b@4f60b314ce95c9b9> <nnd$0a3352ed$2c40f494@296559c013ec38eb>
From: albert@spenarnc.xs4all.nl
Subject: Re: "Back & Forth" - Local variables
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$24c65e7e$1eb23494@5fa571a46b879ee7>
Organization: KPN B.V.
Date: Fri, 10 Jan 2025 11:53:46 +0100
Path: ...!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feed.abavia.com!abe005.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 62
Injection-Date: Fri, 10 Jan 2025 11:53:46 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
Bytes: 2735
In article <nnd$0a3352ed$2c40f494@296559c013ec38eb>,
<albert@spenarnc.xs4all.nl> wrote:
>In article <nnd$75b7a2a4$616fdd6b@4f60b314ce95c9b9>,
>Hans Bezemer <the.beez.speaks@gmail.com> wrote:
<SNIP>
>>https://www.youtube.com/watch?v=Y7cax2fDS84
>
>I was impressed with the Behringer solution.
>(I didn't care about the politically correct solution.)
>
>====================================
>: local{ R> SWAP DUP >R @ >R >R ;
>: }global R> R> R> ! >R ;
>=================
>
>But I can do you one better.
>Remember the word ;: from colorforth. That is actually a coroutine call.
>I call it CO. (Present in ciforth since the year 00)
>
>An example of its use is the following:
>:NONAME .S ; ' LIST decorated
>decorated is not the point. The noname decorates LIST with
>the anonymous function, so that the stack is printed, before LIST.
>Now we go one step further:
>:NONAME .S CO ." AFTER " .S ; ' LIST decorated
Or
:NONAME .S ;: ." AFTER " .S ; ' LIST decorated
>The noname decorates LIST with the anonymous function, so that the
>stack is printed, before, but now noname is suspended, LIST is
>executed as a coroutine, and afterword the stack is printed once more.
>
>With CO the example become
>---------------------------------------
>: LOCAL R> SWAP DUP >R @ >R >R CO R> R> ! ;
>
>VARIABLE A
>VARIABLE B
>
>: divide
> A LOCAL
> B LOCAL
> B ! A ! A @ B @ /
> . CR
>;
>
>15 3 divide
>---------------------------------------
Suppose we adopt Chuck Moore's name
: LOCAL R> SWAP DUP >R @ >R >R ;: R> R> ! ;
This looks even better.
>Groetjes Albert
--
Temu exploits Christians: (Disclaimer, only 10 apostles)
Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
And Gifts For Friends Family And Colleagues.