Re: "Back & Forth" - Local variables

Liste des GroupesRevenir à cl forth 
Sujet : Re: "Back & Forth" - Local variables
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forth
Date : 12. Mar 2025, 01:41:44
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <ebcf3e5fcce3711335c869759599da585006e440@i2pn2.org>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On 11/03/2025 10:25 pm, albert@spenarnc.xs4all.nl wrote:
In article <775ad5020b3de3cc091ce71506dd0ac5fac16523@i2pn2.org>,
dxf  <dxforth@gmail.com> wrote:
On 9/01/2025 6:13 am, albert@spenarnc.xs4all.nl wrote:
In article <nnd$032b844d$734ee136@776df242e330d1d2>,
Hans Bezemer  <the.beez.speaks@gmail.com> wrote:
On 08-01-2025 17:27, albert@spenarnc.xs4all.nl wrote:
>
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)
>
<snipped>
>
>
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
---------------------------------------
>
This saves a definition and a word-of-code, and a line for every
LOCAL used. Now that is closer to what Chuck Moore would have used.
Remember for Moore CO aka ;: is a standard word.
>
CO is not standard but it should be, and it is elementary as hell.
>
Couldn't find the source for either CO or ;: but I got some primitive,
high level form of co-routine in 4tH:
>
====================================
: yield r> r> swap >r >r ;             \ remember that ; compiles EXIT!
aka rdrop grab                         \ so add a [FORCE] when needed.
====================================
>
That is the equivalent in high level code.
>
In assembler, assuming ESI is the interpreter pointer and EBP is the return
stack pointer:
>
CODE CO
            XCHG    ESI,[EBP]
            NEXT,
END-CODE
>
In assembler the return stack is uncluttered.
...
>
Just to clarify CO (coroutines) and
>
: ;:  >r ;
>
are different albeit related beasts.  So which one is Moore's?
>
BTW the latter is equivalent to the 'docol' run-time in most DTC forth.
In my case I'd just need to give the code fragment a name.  But is this
latter ;: worth it?  Its use seems to be restricted to restoring state
when a word completes.  It's not a "coroutine.
 
The code of ;: doesn't clarify anything.
How it can be equivalent to docol which is the label  of
common low level code for colon definition is unclear.
...

Code equivalence is nothing new.  It's for sake of clarity that Fig-forth
defined both I and R@ despite them sharing the same code.  Forth-83 made
the mistake of repurposing NOT because one could use 0= instead.  I don't
wish to make the opposite mistake ... adding a word to the kernel I may
never use.


Date Sujet#  Auteur
8 Jan 25 * "Back & Forth" - Local variables39Hans Bezemer
8 Jan 25 +- Re: "Back & Forth" - Local variables1dxf
8 Jan 25 `* Re: "Back & Forth" - Local variables37albert
8 Jan 25  +* Re: "Back & Forth" - Local variables21Hans Bezemer
8 Jan 25  i`* Re: "Back & Forth" - Local variables20albert
8 Jan 25  i +* Re: "Back & Forth" - Local variables2mhx
9 Jan 25  i i`- Re: "Back & Forth" - Local variables1albert
11 Mar 25  i `* Re: "Back & Forth" - Local variables17dxf
11 Mar 25  i  +- Re: "Back & Forth" - Local variables1dxf
11 Mar 25  i  +* Re: "Back & Forth" - Local variables4Hans Bezemer
12 Mar 25  i  i`* Re: "Back & Forth" - Local variables3dxf
12 Mar 25  i  i +- Re: "Back & Forth" - Local variables1albert
13 Mar 25  i  i `- Re: "Back & Forth" - Local variables1dxf
12 Mar 25  i  `* Re: "Back & Forth" - Local variables11dxf
13 Mar 25  i   `* Re: "Back & Forth" - Local variables10sjack
14 Mar 25  i    `* Re: "Back & Forth" - Local variables9dxf
14 Mar 25  i     +* Re: "Back & Forth" - Local variables2sjack
14 Mar 25  i     i`- Re: "Back & Forth" - Local variables1sjack
16 Mar 25  i     `* Re: "Back & Forth" - Local variables6Hans Bezemer
16 Mar 25  i      `* Re: "Back & Forth" - Local variables5sjack
16 Mar 25  i       +- Re: "Back & Forth" - Local variables1sjack
17 Mar 25  i       +- Re: "Back & Forth" - Local variables1sjack
17 Mar 25  i       `* Re: "Back & Forth" - Local variables2sjack
18 Mar 25  i        `- Re: "Back & Forth" - Local variables1dxf
8 Jan 25  +* Re: "Back & Forth" - Local variables13Hans Bezemer
8 Jan 25  i`* Re: "Back & Forth" - Local variables12dxf
9 Jan 25  i `* Re: "Back & Forth" - Local variables11dxf
9 Jan 25  i  +* Re: "Back & Forth" - Local variables9albert
9 Jan 25  i  i+* Re: "Back & Forth" - Local variables7dxf
9 Jan 25  i  ii`* Re: "Back & Forth" - Local variables6Hans Bezemer
10 Jan 25  i  ii +* Re: "Back & Forth" - Local variables4dxf
10 Jan 25  i  ii i+- Re: "Back & Forth" - Local variables1Hans Bezemer
10 Jan 25  i  ii i`* Re: "Back & Forth" - Local variables2sjack
10 Jan 25  i  ii i `- Re: "Back & Forth" - Local variables1dxf
10 Jan 25  i  ii `- Re: "Back & Forth" - Local variables1albert
9 Jan 25  i  i`- xts and return addresses (was: "Back & Forth" - Local variables)1Anton Ertl
9 Jan 25  i  `- Re: "Back & Forth" - Local variables1sjack
10 Jan 25  `* Re: "Back & Forth" - Local variables2albert
10 Jan 25   `- Re: "Back & Forth" - Local variables1Hans Bezemer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal