Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Spock: The odds of surviving another attack are 13562190123 to 1, Captain.


devel / comp.lang.forth / Re: Not really locals

SubjectAuthor
* Not really localsPaul Rubin
+* Re: Not really localsPaul Rubin
|`- Re: Not really localsHans Bezemer
+- Re: Not really localsMarcel Hendrix
+* Re: Not really localsAnton Ertl
|+- Re: Not really localsP Falth
|`* Re: Not really localsdxforth
| +* Re: Not really localsPaul Rubin
| |`* Re: Not really localsdxforth
| | `* Re: Not really localsPaul Rubin
| |  +* Re: Not really localsMarcel Hendrix
| |  |`- Re: Not really localsAnton Ertl
| |  +* Re: Not really localsdxforth
| |  |`- Re: Not really localsPaul Rubin
| |  `* Re: Not really localsAndy Valencia
| |   `* Re: Not really localsdxforth
| |    `* Re: Not really localsPaul Rubin
| |     `* Re: Not really localsdxforth
| |      `* Re: Not really localsPaul Rubin
| |       `- Re: Not really localsdxforth
| `* Re: Not really localsDoug Hoffman
|  `* Re: Not really localsPaul Rubin
|   `* Re: Not really localsAnton Ertl
|    +* Re: Not really localsDoug Hoffman
|    |`- Re: Not really localsAnton Ertl
|    `* Re: Not really localsPaul Rubin
|     +* Re: Not really localsdxforth
|     |`* Re: Not really localsPaul Rubin
|     | +* Re: Not really localsdxforth
|     | |`- Re: Not really localsPaul Rubin
|     | +* Re: Not really localsHans Bezemer
|     | |+* Re: Not really localsHugh Aguilar
|     | ||`* Re: Not really localsdxforth
|     | || `* Re: Not really localsHugh Aguilar
|     | ||  `* Re: Not really localsdxforth
|     | ||   `* Re: Not really localsHugh Aguilar
|     | ||    `- Re: Not really localsdxforth
|     | |`* Re: Not really localsPaul Rubin
|     | | `* Re: Not really localsdxforth
|     | |  `* Re: Not really localsPaul Rubin
|     | |   +- Re: Not really localsdxforth
|     | |   +- Re: Not really localsHugh Aguilar
|     | |   `* Re: Not really localsdxforth
|     | |    `* Re: Not really localsPaul Rubin
|     | |     `* Re: Not really localsdxforth
|     | |      `* Re: Not really localsPaul Rubin
|     | |       `* Re: Not really localsdxforth
|     | |        `* Re: Not really localsPaul Rubin
|     | |         `* Re: Not really localsHans Bezemer
|     | |          +* Re: Not really localsminf...@arcor.de
|     | |          |`* Re: Not really localsdxforth
|     | |          | +- Re: Not really localsminf...@arcor.de
|     | |          | `- Re: Not really localsHans Bezemer
|     | |          +* Re: Not really localsPaul Rubin
|     | |          |`* Re: Not really localsdxforth
|     | |          | `* Re: Not really localsPaul Rubin
|     | |          |  +* Re: Not really localsdxforth
|     | |          |  |+* Re: Not really localsS Jack
|     | |          |  ||`- Re: Not really localsHugh Aguilar
|     | |          |  |`- Re: Not really localsPaul Rubin
|     | |          |  `* Re: Not really localsdxforth
|     | |          |   +* Re: Not really localsPaul Rubin
|     | |          |   |+- Re: Not really localsdxforth
|     | |          |   |`* Re: Not really localsHans Bezemer
|     | |          |   | `* Re: Not really localsHans Bezemer
|     | |          |   |  +* Re: Not really localsPaul Rubin
|     | |          |   |  |+- Re: Not really localsPaul Rubin
|     | |          |   |  |`* Re: Not really localsminf...@arcor.de
|     | |          |   |  | +* Re: Not really localsPaul Rubin
|     | |          |   |  | |`* Re: Not really localsHans Bezemer
|     | |          |   |  | | +* Re: Not really localsdxforth
|     | |          |   |  | | |`- Re: Not really localsdxforth
|     | |          |   |  | | `* Re: Not really localsPaul Rubin
|     | |          |   |  | |  +* Re: Not really localsHans Bezemer
|     | |          |   |  | |  |`- Re: Not really localsPaul Rubin
|     | |          |   |  | |  `- Re: Not really localsdxforth
|     | |          |   |  | `* Re: Not really localsAndy Valencia
|     | |          |   |  |  +* Re: Not really localsMarcel Hendrix
|     | |          |   |  |  |+- Re: Not really localsAnton Ertl
|     | |          |   |  |  |`- Re: Not really localsS Jack
|     | |          |   |  |  +* Re: Not really localsAndy Valencia
|     | |          |   |  |  |+- Re: Not really localsdxforth
|     | |          |   |  |  |+* Re: Not really localsMarcel Hendrix
|     | |          |   |  |  ||`- Re: Not really localsminf...@arcor.de
|     | |          |   |  |  |`- Re: Not really localsAndy Valencia
|     | |          |   |  |  `* Re: Not really localsHans Bezemer
|     | |          |   |  |   `* Re: Not really localsPaul Rubin
|     | |          |   |  |    +* Re: Not really localsAnton Ertl
|     | |          |   |  |    |`* Re: Not really localsHans Bezemer
|     | |          |   |  |    | +* Re: Not really localsPaul Rubin
|     | |          |   |  |    | |+- Re: Not really localsdxforth
|     | |          |   |  |    | |+* static type checking (was: Not really locals)Anton Ertl
|     | |          |   |  |    | ||`- Re: static type checkingPaul Rubin
|     | |          |   |  |    | |`* Re: Not really localsS Jack
|     | |          |   |  |    | | +- Re: Not really localsDoug Hoffman
|     | |          |   |  |    | | `- Re: Not really localsdxforth
|     | |          |   |  |    | `* Re: Not really localsAnton Ertl
|     | |          |   |  |    |  +- Re: Not really localsHans Bezemer
|     | |          |   |  |    |  `* Re: Not really localsPaul Rubin
|     | |          |   |  |    |   +* Re: Not really localsHans Bezemer
|     | |          |   |  |    |   |`- Re: Not really localsdxforth
|     | |          |   |  |    |   +* Re: Not really localsS Jack
|     | |          |   |  |    |   `- Re: Not really localsdxforth
|     | |          |   |  |    `* Re: Not really localsdxforth
|     | |          |   |  `* Re: Not really localsdxforth
|     | |          |   `- Re: Not really localsAnton Ertl
|     | |          `* Re: Not really localsRuvim
|     | +- Re: Not really localsMarcel Hendrix
|     | `- Re: Not really localsMarcel Hendrix
|     `* Re: Not really localsAnton Ertl
+* Re: Not really localsS Jack
`- Re: Not really localsHugh Aguilar

Pages:1234567
Re: Not really locals

<877dftspq8.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14509&group=comp.lang.forth#14509

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 06 Sep 2021 08:11:59 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <877dftspq8.fsf@nightsong.com>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="c21c2ba976cb35b25d4004aa6d240f1b";
logging-data="11958"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nuiuLe+h/GTyPlcfEo+Bl"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:eKl4IR7XYUtdvCpMkO2+NQUCom4=
sha1:u0G6hGrLeELbHeFizzdkkhN1b68=
 by: Paul Rubin - Mon, 6 Sep 2021 15:11 UTC

dxforth <dxforth@gmail.com> writes:
> So you're creating a forth? Care to share some details - target cpu,
> language used to implement etc.

Target cpu ATTiny1616 and similar. Bytecode interpreter (in asm) for
Forth VM on the target, metacompiler/tethered host on remote machine.
Metacompiler might be written in Gforth for Forth points, or might be
something like Python.

I started something like this for the STM8 a while back, but had to put
it aside. That one worked a bit differently using an ITC-like approach,
but I decided after a while that bytecode is less hassle. This thing
needs to be compact on the target, but not especially fast.

The target application is mostly written in C, so the Forth would be
used for debugging, interactive experiments, and user extensions.

Re: Not really locals

<sh6f2p$h91$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14510&group=comp.lang.forth#14510

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Tue, 7 Sep 2021 11:25:45 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sh6f2p$h91$1@gioia.aioe.org>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="17697"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Tue, 7 Sep 2021 01:25 UTC

On 7/09/2021 01:11, Paul Rubin wrote:
> dxforth <dxforth@gmail.com> writes:
>> So you're creating a forth? Care to share some details - target cpu,
>> language used to implement etc.
>
> Target cpu ATTiny1616 and similar. Bytecode interpreter (in asm) for
> Forth VM on the target, metacompiler/tethered host on remote machine.
> Metacompiler might be written in Gforth for Forth points, or might be
> something like Python.
>
> I started something like this for the STM8 a while back, but had to put
> it aside. That one worked a bit differently using an ITC-like approach,
> but I decided after a while that bytecode is less hassle. This thing
> needs to be compact on the target, but not especially fast.
>
> The target application is mostly written in C, so the Forth would be
> used for debugging, interactive experiments, and user extensions.

So that's either C or Forth running? Is there an existing forth
you're using as a model?

I had a closer look at the stack usage for the multitasking example.
Excluding memory for USER variables and HOLD buffer, I measure the
running task required 15 cells data stack (3 for task switch) and
7 cells of return stack.

Re: Not really locals

<8735qhrvla.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14511&group=comp.lang.forth#14511

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 06 Sep 2021 19:02:57 -0700
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <8735qhrvla.fsf@nightsong.com>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="cca79e009fedd71a97a1d157f7d70834";
logging-data="22680"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ICQ7N6cmC5SvL4DjM+NLn"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:0cugWPkwp134E2CInuhwerkHaWE=
sha1:KcR78aEvkqxshe0RW31gu7yzX0I=
 by: Paul Rubin - Tue, 7 Sep 2021 02:02 UTC

dxforth <dxforth@gmail.com> writes:
> So that's either C or Forth running? Is there an existing forth
> you're using as a model?

Yeah basically, it's a C program but you could tell it to call the Forth
VM as a subroutine. The VM would be an asm version of this, since
compiling the C version gave around 2KB of code and it should be maybe
1/4 of that:

http://chiselapp.com/user/tehologist/repository/compc/home

There is also an old Forth Dimensions article about metacompilers that I
think was written by Brad Rodriguez, that I'd follow for the remote
side. I'll have to find it again.

I notice Chuck Moore's chips and MPE's more recent VM paper adds some
registers to the stack as part of the VM:

http://www.complang.tuwien.ac.at/anton/euroforth/ef08/papers/pelc.pdf

So I could add something like that if it looks useful. Also, FlashForth
has an extra stack (the P stack) for temporary values. I will look at
how it works.

> running task required 15 cells data stack (3 for task switch) and
> 7 cells of return stack.

I think this is fine, the ATTiny16 has 1K of ram and using a few hundred
bytes of it for Forth shouldn't be a problem. There would be a bunch of
variables shared with the C program that wouldn't "count".

Re: Not really locals

<0956b849-35f3-4f21-8b17-f369f69d63c6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14512&group=comp.lang.forth#14512

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:44e:: with SMTP id o14mr8272401qtx.33.1630980806094; Mon, 06 Sep 2021 19:13:26 -0700 (PDT)
X-Received: by 2002:a37:a80c:: with SMTP id r12mr13641411qke.299.1630980805948; Mon, 06 Sep 2021 19:13:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 6 Sep 2021 19:13:25 -0700 (PDT)
In-Reply-To: <sh49sf$1ggs$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:579:8018:1b00:5d5:5dd4:ba08:454d; posting-account=OxDKOgoAAADW0cxAqHqpN1zqeCoSsDap
NNTP-Posting-Host: 2001:579:8018:1b00:5d5:5dd4:ba08:454d
References: <87mtp3ux27.fsf@nightsong.com> <2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org> <612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com> <2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com> <842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com> <1fc5cadd-914d-4ab3-bbaa-e95e8a9206a8n@googlegroups.com> <sh1dt5$12tr$1@gioia.aioe.org> <170af0dc-a586-4d84-99fe-b9d9cefd26den@googlegroups.com> <sh49sf$1ggs$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0956b849-35f3-4f21-8b17-f369f69d63c6n@googlegroups.com>
Subject: Re: Not really locals
From: hughagui...@gmail.com (Hugh Aguilar)
Injection-Date: Tue, 07 Sep 2021 02:13:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 42
 by: Hugh Aguilar - Tue, 7 Sep 2021 02:13 UTC

On Sunday, September 5, 2021 at 10:44:50 PM UTC-7, dxforth wrote:
> On 6/09/2021 09:47, Hugh Aguilar wrote:
> > On Saturday, September 4, 2021 at 8:35:03 PM UTC-7, dxforth wrote:
> >> On 5/09/2021 08:40, Hugh Aguilar wrote:
> >> >
> >> > I have yet to find anybody on comp.lang.forth who understands the concept of
> >> > general-purpose data-structures. Do you? Can you explain this concept?
> >> General-purpose data-structures implies lots of parameter passing which
> >> necessitates locals. Did I get it right?
> >
> > No. You are not even close. You don't know what rquotations do,
> > and you don't know what a general-purpose data-structure is.
> >
> > I haven't forgotten about how you mocked me by using the term "disambiguifier"
> > for some kindergarten-level code that you wrote.
> > You either don't know anything about that subject, or you were just acting stupid
> > for the purpose of annoying me.

> Disambiguifiers were aimed at kindergarten-level users to convince them
> how broken was ANS, and by implication those behind it.

Given the disambiguifiers I was able to write an early-binding MACRO: and POST: etc.
that are far superior to Anton Ertl's ridiculous ]] because they support literals as well
as words that take data out of the input stream such as [CHAR] POSTPONE etc..
You don't don't what you are talking about, so STFU!

> So it's been
> for your general-purpose code routines - thinly-veiled expositions on
> how ANS got it wrong. In the meantime they do the opposite.

This isn't true either. My general-purpose data-structures are useful for writing
application programs. I rely on this code for writing programs, such as the MSP430 assembler.
You don't don't what you are talking about, so STFU!

> One has
> to travel a long way in Forth to get past the pro/anti-ANS lobby.

I want you to travel a long way, and not come back.
I have had enough of you attacking me with this idiotic nonsense.
You don't know anything about programming. You are just an annoying idiot.

> > Stop pestering me with idiotic nonsense --- I don't think that you know anything
> > about programming at all --- I don't want to hear anything further from you.

Re: Not really locals

<sh6l4t$ic9$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14513&group=comp.lang.forth#14513

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Tue, 7 Sep 2021 13:09:18 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sh6l4t$ic9$1@gioia.aioe.org>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="18825"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Tue, 7 Sep 2021 03:09 UTC

On 7/09/2021 12:02, Paul Rubin wrote:
>
> I notice Chuck Moore's chips and MPE's more recent VM paper adds some
> registers to the stack as part of the VM:
>
> http://www.complang.tuwien.ac.at/anton/euroforth/ef08/papers/pelc.pdf
>
> So I could add something like that if it looks useful. Also, FlashForth
> has an extra stack (the P stack) for temporary values. I will look at
> how it works.

I suspect diminishing returns if one has to simulate it. The classic VM
requires a fancy optimizer to get any performance out of it.

Re: Not really locals

<sh6ngn$194q$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14514&group=comp.lang.forth#14514

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Tue, 7 Sep 2021 13:49:43 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sh6ngn$194q$1@gioia.aioe.org>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<1fc5cadd-914d-4ab3-bbaa-e95e8a9206a8n@googlegroups.com>
<sh1dt5$12tr$1@gioia.aioe.org>
<170af0dc-a586-4d84-99fe-b9d9cefd26den@googlegroups.com>
<sh49sf$1ggs$1@gioia.aioe.org>
<0956b849-35f3-4f21-8b17-f369f69d63c6n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="42138"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Tue, 7 Sep 2021 03:49 UTC

On 7/09/2021 12:13, Hugh Aguilar wrote:
> On Sunday, September 5, 2021 at 10:44:50 PM UTC-7, dxforth wrote:
>
>> So it's been
>> for your general-purpose code routines - thinly-veiled expositions on
>> how ANS got it wrong. In the meantime they do the opposite.
>
> This isn't true either. My general-purpose data-structures are useful for writing
> application programs. I rely on this code for writing programs, such as the MSP430 assembler.
> You don't don't what you are talking about, so STFU!

Library code is only as good as the applications written with them.
Feel free to post your completed apps (https://pastebin.com/) and
folks can judge for themselves.

Re: Not really locals

<87y289q9m7.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14515&group=comp.lang.forth#14515

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 06 Sep 2021 21:42:56 -0700
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <87y289q9m7.fsf@nightsong.com>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="cca79e009fedd71a97a1d157f7d70834";
logging-data="15222"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qR5MfuNFmY6zE6Cv1GD0j"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:OD9tkhG5/tZIh7A6RDPFjjXb40g=
sha1:ydKXbAEW36pDJT/4ix5J++9Ir90=
 by: Paul Rubin - Tue, 7 Sep 2021 04:42 UTC

dxforth <dxforth@gmail.com> writes:
> I suspect diminishing returns if one has to simulate it. The classic VM
> requires a fancy optimizer to get any performance out of it.

I think runtime speed is not really an issue here. The idea is to make
coding easier, and maybe to make the code a little smaller.

Re: Not really locals

<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14517&group=comp.lang.forth#14517

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5c96:: with SMTP id r22mr14834667qta.267.1631009547540;
Tue, 07 Sep 2021 03:12:27 -0700 (PDT)
X-Received: by 2002:a37:2dc7:: with SMTP id t190mr14890509qkh.60.1631009547376;
Tue, 07 Sep 2021 03:12:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 7 Sep 2021 03:12:27 -0700 (PDT)
In-Reply-To: <87y289q9m7.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <87mtp3ux27.fsf@nightsong.com> <2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org> <612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com> <2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com> <842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org> <87y289q9m7.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
Subject: Re: Not really locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Tue, 07 Sep 2021 10:12:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 72
 by: Hans Bezemer - Tue, 7 Sep 2021 10:12 UTC

On Tuesday, September 7, 2021 at 6:42:59 AM UTC+2, Paul Rubin wrote:
> dxforth <dxf...@gmail.com> writes:
> > I suspect diminishing returns if one has to simulate it. The classic VM
> > requires a fancy optimizer to get any performance out of it.
> I think runtime speed is not really an issue here. The idea is to make
> coding easier, and maybe to make the code a little smaller.
Oh, I agree with dxforth here. It's not rocket science to implement this proposal. However, given this will be done by variables and stuff - it won't make programs run faster.
And easier: if you want to go "easier" the 4tH preprocessor allows you to write code like this:

: calculate ( -- flag)
let f = f - u;
let h = h - v;
let v = (((v + g) * 10) - (u * 2)) / 10;
let h,|0> 0=|; \ height < 1?
;

Now you got your "easier". But if you want to go "easy" there are better suited languages for this. Forth is a pretty nice language. It allows you to bolt on virtually everything you want - if you want "easier". However, it's YOUR choice to do so. Don't make it my choice by trying to get it into the standard by proposing laughable extensions like ^1 ^2.

Note that if you do this in Forth, your first ^1 isn't your second ^1, because now ^1 is ^2. So in that case it's either a fancy ROLL or you gotta save some pointer to prevent ^1 becoming ^2. And THAT is function call overhead. You suffer the same penalty with LOCALs, since ; will have to clean up your mess.

And I don't like you messing with my VM, just because you want to make "things easy". I got my things "easy". I write stuff much faster in Forth than I do in C. That you can't fathom raw Forth is NOT my problem - and I won't make it my problem either.

I know things can get tricky when your stack needs to keep track of three elements or more. And some routines simply require that many parameters. I solved this partially by creating three read-only "registers" on the return stack R@, R'@ and R"@. I can even AKA the darn things to keep the source readable.

aka r@ x0
aka r'@ y0

: circle ( x y radius --)
swap >r swap >r 1 over - swap 0 ( dp x y R: x0 y0)

begin
over x0 + over y0 + set_pixel ( x0 + x, y0 + y)
over x0 swap - over y0 + set_pixel ( x0 - x, y0 + y)
over x0 + over y0 swap - set_pixel ( x0 + x, y0 - y)
over x0 swap - over y0 swap - set_pixel ( x0 - x, y0 - y)
over y0 + over x0 + swap set_pixel ( x0 + y, y0 + x)
over y0 + over x0 swap - swap set_pixel ( x0 - y, y0 + x)
over y0 swap - over x0 + swap set_pixel ( x0 + y, y0 - x)
over y0 swap - over x0 swap - swap set_pixel ( x0 - y, y0 - x)
( dp x y R: x0 y0)
1+ >r over 0> if 1- r@ over - else r@ then 2* 1+ rot + swap r>
over over < ( dp x y f R: x0 y0)
until drop drop drop r> drop r> drop
;

[DEFINED] 4TH# [IF]
hide x0
hide y0
[THEN]

And yes, you still have to keep on thinking and planning. That's Forth. Deal with it. https://sourceforge.net/p/forth-4th/wiki/This%20is%20Forth/

Hans Bezemer

Re: Not really locals

<b671d481-e94f-4ef8-b79d-6ca03e40b2d6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14518&group=comp.lang.forth#14518

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:1035:: with SMTP id a21mr15867498qkk.422.1631022876245;
Tue, 07 Sep 2021 06:54:36 -0700 (PDT)
X-Received: by 2002:a05:622a:1911:: with SMTP id w17mr16137920qtc.228.1631022876082;
Tue, 07 Sep 2021 06:54:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 7 Sep 2021 06:54:35 -0700 (PDT)
In-Reply-To: <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f0f:8fb8:49c0:636b:923b:1d74;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f0f:8fb8:49c0:636b:923b:1d74
References: <87mtp3ux27.fsf@nightsong.com> <2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org> <612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com> <2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com> <842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com> <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b671d481-e94f-4ef8-b79d-6ca03e40b2d6n@googlegroups.com>
Subject: Re: Not really locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Tue, 07 Sep 2021 13:54:36 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 46
 by: minf...@arcor.de - Tue, 7 Sep 2021 13:54 UTC

the.bee...@gmail.com schrieb am Dienstag, 7. September 2021 um 12:12:28 UTC+2:
> On Tuesday, September 7, 2021 at 6:42:59 AM UTC+2, Paul Rubin wrote:
> > dxforth <dxf...@gmail.com> writes:
> > > I suspect diminishing returns if one has to simulate it. The classic VM
> > > requires a fancy optimizer to get any performance out of it.
> > I think runtime speed is not really an issue here. The idea is to make
> > coding easier, and maybe to make the code a little smaller.
> Oh, I agree with dxforth here. It's not rocket science to implement this proposal. However, given this will be done by variables and stuff - it won't make programs run faster.
> And easier: if you want to go "easier" the 4tH preprocessor allows you to write code like this:
>
> : calculate ( -- flag)
> let f = f - u;
> let h = h - v;
> let v = (((v + g) * 10) - (u * 2)) / 10;
> let h,|0> 0=|; \ height < 1?
> ;
>
> Now you got your "easier". But if you want to go "easy" there are better suited languages for this. Forth is a pretty nice language. It allows you to bolt on virtually everything you want - if you want "easier". However, it's YOUR choice to do so. Don't make it my choice by trying to get it into the standard by proposing laughable extensions like ^1 ^2.
>

Nice and impressive!

In MY choice Forth I can/could define
: MYROT { a b c == b c a } ;
: MYOVER { a b == a b a } ;
: MYFOVER { F: a b == a b a } ;

The locals parser is extended to define all required locals of any type and
to push "output locals" to the stack before leaving the word.
This is implemented as rather simple extension of standard Forth locals scheme.

Of course a.m. examples are overly simple and show only the basic idea.
In reality e.g. calculations with complex numbers and arrays, code becomes
really elegant and readable. Without that extension I would have left Forth
behind long ago.

Re: Not really locals

<sh990n$8nk$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14519&group=comp.lang.forth#14519

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 8 Sep 2021 13:00:40 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sh990n$8nk$1@gioia.aioe.org>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<b671d481-e94f-4ef8-b79d-6ca03e40b2d6n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="8948"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Wed, 8 Sep 2021 03:00 UTC

On 7/09/2021 23:54, minf...@arcor.de wrote:
>
> Of course a.m. examples are overly simple and show only the basic idea.
> In reality e.g. calculations with complex numbers and arrays, code becomes
> really elegant and readable. Without that extension I would have left Forth
> behind long ago.

It begs the question why stay with forth. Moore wrote a BASIC compiler to
show that he could - not because he might one day need it. Forth doesn't
exist to solve problems other languages already handle (better in the opinion
of some). It exists for its differences.

Forth with its absurd numbers of small definitions replaces the parameter
and structure laden, page-long, multi-indented definition approach of other
languages. Were they the same and appealed to the same people, Forth would
have no reason to exist.

Re: Not really locals

<87h7ev6832.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14520&group=comp.lang.forth#14520

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Tue, 07 Sep 2021 20:48:33 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <87h7ev6832.fsf@nightsong.com>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ac82e9b28adc83a3f5f6ab02d889e17b";
logging-data="9354"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18APFhqowB0kFnuHMv+NhoF"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:FjBQpNT7fb91GTVXKRAkP+UNVw8=
sha1:MhUyUPz0l3bfSim+xALj0z9aGAg=
 by: Paul Rubin - Wed, 8 Sep 2021 03:48 UTC

Hans Bezemer <the.beez.speaks@gmail.com> writes:
> Now you got your "easier". But if you want to go "easy" there are
> better suited languages for this.

What kind of recommendation for Forth is that, to say it makes things
unnecessarily hard? Some of us want to get our stuff done without
jumping through extra hoops simply because we can.

> I solved this partially by creating three read-only "registers" on the
> return stack R@, R'@ and R"@. I can even AKA the darn things to keep
> the source readable.

That sounds like locals ;-).
> : circle ( x y radius --)
> swap >r swap >r 1 over - swap 0 ( dp x y R: x0 y0)

: circle {: x0 y0 r :} ... ;

> And yes, you still have to keep on thinking and planning. That's
> Forth. Deal with it.
> https://sourceforge.net/p/forth-4th/wiki/This%20is%20Forth/

"Now, does it run faster? Hardly. Is it any shorter. Not much, if
any. Is it easier to maintain? Only for Forth programmers, I think. So
why bother? Because this is Forth.."

I dunno, I don't see how it's easier for even Forth programmers to
maintain. It just seems like masochism.

Re: Not really locals

<sh9gfq$ebl$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14521&group=comp.lang.forth#14521

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!rocksolid2!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 8 Sep 2021 15:08:12 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sh9gfq$ebl$1@gioia.aioe.org>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<87h7ev6832.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="14709"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Wed, 8 Sep 2021 05:08 UTC

On 8/09/2021 13:48, Paul Rubin wrote:
>
> That sounds like locals ;-).
>> : circle ( x y radius --)
>> swap >r swap >r 1 over - swap 0 ( dp x y R: x0 y0)
>
> : circle {: x0 y0 r :} ... ;
>
>> And yes, you still have to keep on thinking and planning. That's
>> Forth. Deal with it.
>> https://sourceforge.net/p/forth-4th/wiki/This%20is%20Forth/
>
> "Now, does it run faster? Hardly. Is it any shorter. Not much, if
> any. Is it easier to maintain? Only for Forth programmers, I think. So
> why bother? Because this is Forth.."
>
> I dunno, I don't see how it's easier for even Forth programmers to
> maintain. It just seems like masochism.

Circle is defined once and likely won't be changed. What is there to
maintain? The problem with locals is that if one can justify its use
in one function, why not use it everywhere - which has a multiplying
effect on performance. Far from being masochism, forth and the stack
gets easier as one uses it and it's locals that begin to look like the
odd man out - which of course they are.

Re: Not really locals

<b9903e43-6a5f-4995-a62c-841cf813c200n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14522&group=comp.lang.forth#14522

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:44b4:: with SMTP id a20mr2215911qto.166.1631081761564;
Tue, 07 Sep 2021 23:16:01 -0700 (PDT)
X-Received: by 2002:a0c:e0c7:: with SMTP id x7mr2222868qvk.55.1631081761439;
Tue, 07 Sep 2021 23:16:01 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 7 Sep 2021 23:16:01 -0700 (PDT)
In-Reply-To: <sh990n$8nk$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f0f:8f9a:ccbc:548d:c4bd:bc57;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f0f:8f9a:ccbc:548d:c4bd:bc57
References: <87mtp3ux27.fsf@nightsong.com> <2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org> <612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com> <2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com> <842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com> <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<b671d481-e94f-4ef8-b79d-6ca03e40b2d6n@googlegroups.com> <sh990n$8nk$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b9903e43-6a5f-4995-a62c-841cf813c200n@googlegroups.com>
Subject: Re: Not really locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 08 Sep 2021 06:16:01 +0000
Content-Type: text/plain; charset="UTF-8"
 by: minf...@arcor.de - Wed, 8 Sep 2021 06:16 UTC

dxforth schrieb am Mittwoch, 8. September 2021 um 05:00:42 UTC+2:
> On 7/09/2021 23:54, minf...@arcor.de wrote:
> >
> > Of course a.m. examples are overly simple and show only the basic idea.
> > In reality e.g. calculations with complex numbers and arrays, code becomes
> > really elegant and readable. Without that extension I would have left Forth
> > behind long ago.
>
> It begs the question why stay with forth. Moore wrote a BASIC compiler to
> show that he could - not because he might one day need it. Forth doesn't
> exist to solve problems other languages already handle (better in the opinion
> of some). It exists for its differences.

It is no language question, it is MY answer to get the job done. I use Forth
in a restricted multitasking environment (controller) where Forth excels per se.
And with proper DSL extensions I can do higher math and signal processing
on the same software core.

Language purists live in virtual reality and are mostly unproductive.

Re: Not really locals

<87y287qy7c.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14523&group=comp.lang.forth#14523

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 08 Sep 2021 01:16:23 -0700
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <87y287qy7c.fsf@nightsong.com>
References: <87mtp3ux27.fsf@nightsong.com> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<87h7ev6832.fsf@nightsong.com> <sh9gfq$ebl$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ac82e9b28adc83a3f5f6ab02d889e17b";
logging-data="22549"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3ZX8CxJwxbNdzCUOUU4Nj"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:R6UZ55e78hN71qhRzDIDKSItPBY=
sha1:0wG1Anskj9ynhFSA5Nu09vrLQnU=
 by: Paul Rubin - Wed, 8 Sep 2021 08:16 UTC

dxforth <dxforth@gmail.com> writes:
> The problem with locals is that if one can justify its use in one
> function, why not use it everywhere - which has a multiplying effect
> on performance.

Ok, maybe using locals everywhere slows down the program by 2x. I doubt
that, but just suppose. I'm probably taking a 5x slowdown by using
interpreted Forth instead of compiled C to start with. The additional
2x is still perfectly fine for what I'm doing. And in the Forth spirit,
I can write hot loops in assembler. So now what?

I made a mistake saying the ram capacity of the attiny1616 was 1KB. It
is actually 2KB so there is plenty of ram, even for a multitasker with
stack switching if that looks useful.

> Far from being masochism, forth and the stack gets easier as one uses
> it and it's locals that begin to look like the odd man out - which of
> course they are.

I don't know. In the bigger scheme of things, Forth is the odd man
out. Maybe locals can bring it back into the fold.

An alternative ugly idea: reserve up to 4 or maybe more cells of
registers for temporaries. The AVR has 32 8-bitmachine registers, so
four 16 bit cells this would use 8 of them.

: foo/3 .... ;

(syntax inspired by Erlang which I think was inspired by Prolog) would
save 3 registers on the R stack (the code for that is very compact)
could be referred to as A, B, and C. >A, 2>A, and 3>A would transfer
that many cells from the D stack to A, A B, or A B C. There would
be automatic cleanup on function exit.

Accessing these registers would be faster than doing stack operations,
since they are machine registers and the compiler could generate simple
machine code to use them.

Re: Not really locals

<sha988$10fj$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14524&group=comp.lang.forth#14524

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 8 Sep 2021 22:10:47 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sha988$10fj$1@gioia.aioe.org>
References: <87mtp3ux27.fsf@nightsong.com> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<87h7ev6832.fsf@nightsong.com> <sh9gfq$ebl$1@gioia.aioe.org>
<87y287qy7c.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="33267"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Wed, 8 Sep 2021 12:10 UTC

On 8/09/2021 18:16, Paul Rubin wrote:
> dxforth <dxforth@gmail.com> writes:
>> The problem with locals is that if one can justify its use in one
>> function, why not use it everywhere - which has a multiplying effect
>> on performance.
>
> Ok, maybe using locals everywhere slows down the program by 2x. I doubt
> that, but just suppose. I'm probably taking a 5x slowdown by using
> interpreted Forth instead of compiled C to start with. The additional
> 2x is still perfectly fine for what I'm doing. And in the Forth spirit,
> I can write hot loops in assembler. So now what?

Fighting the language one is coding in doesn't strike me as optimum.

> I made a mistake saying the ram capacity of the attiny1616 was 1KB. It
> is actually 2KB so there is plenty of ram, even for a multitasker with
> stack switching if that looks useful.
>
>> Far from being masochism, forth and the stack gets easier as one uses
>> it and it's locals that begin to look like the odd man out - which of
>> course they are.
>
> I don't know. In the bigger scheme of things, Forth is the odd man
> out. Maybe locals can bring it back into the fold.

'Forth is a stack-based language' ought to have been clear enough.

Re: Not really locals

<3a8061a4-11e4-41c5-9b4c-b789d789d73an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14525&group=comp.lang.forth#14525

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:81d:: with SMTP id s29mr4002556qks.301.1631114549396;
Wed, 08 Sep 2021 08:22:29 -0700 (PDT)
X-Received: by 2002:a37:8a05:: with SMTP id m5mr4094872qkd.44.1631114549194;
Wed, 08 Sep 2021 08:22:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 8 Sep 2021 08:22:29 -0700 (PDT)
In-Reply-To: <sha988$10fj$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:f13b:7ff8:6731:6205;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:f13b:7ff8:6731:6205
References: <87mtp3ux27.fsf@nightsong.com> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com> <87o897sn3l.fsf@nightsong.com>
<sh1j5u$gdi$1@gioia.aioe.org> <87k0jvscg0.fsf@nightsong.com>
<sh4osq$9sn$1@gioia.aioe.org> <877dftspq8.fsf@nightsong.com>
<sh6f2p$h91$1@gioia.aioe.org> <8735qhrvla.fsf@nightsong.com>
<sh6l4t$ic9$1@gioia.aioe.org> <87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com> <87h7ev6832.fsf@nightsong.com>
<sh9gfq$ebl$1@gioia.aioe.org> <87y287qy7c.fsf@nightsong.com> <sha988$10fj$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3a8061a4-11e4-41c5-9b4c-b789d789d73an@googlegroups.com>
Subject: Re: Not really locals
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Wed, 08 Sep 2021 15:22:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 32
 by: S Jack - Wed, 8 Sep 2021 15:22 UTC

On Wednesday, September 8, 2021 many wrote.

I might be in a majority here for once. I seldom use locals, mainly
because its a clash in style, but have no qualms of using them when
I want to.

Don't see anything new being said in this thread. It boils down to
this:
1) The purist:
The more one uses the stack the better at it he will become and
the cost of local sugar is not worth it.
2) The localist:
Locals are convenient and clear where code can reflect written
equations. The sugar is of little cost.

I roll my eyes when I see "Chuck did it this way", "The Forth Way,
"Easier to maintain", "Less mistakes", and "Helping the poor newbie".
There's probably a rhetorical category for such phrases. To me they just
convey someone's delusional "Do it MY way and the world will be a better
place."

I can appreciate dxForth not wanting things in the standard that may
change the character of Forth. Not having to deal with problems
professionals face what's gets in the standard doesn't matter much to me.
That's not to say the ideas and discussions are not of interest.

I make no effort to code to anyone's delusional "The Forth Way"
(have no need to follow) and continue to enjoy cobbling Forth code my
way (have no need of a following).
--
me

"Many can see the obvious; few can see the potential."

Re: Not really locals

<shapgj$1a32$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14526&group=comp.lang.forth#14526

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Thu, 9 Sep 2021 02:48:19 +1000
Organization: Aioe.org NNTP Server
Message-ID: <shapgj$1a32$1@gioia.aioe.org>
References: <87mtp3ux27.fsf@nightsong.com> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<87h7ev6832.fsf@nightsong.com> <sh9gfq$ebl$1@gioia.aioe.org>
<87y287qy7c.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="43106"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Wed, 8 Sep 2021 16:48 UTC

On 8/09/2021 18:16, Paul Rubin wrote:
> dxforth <dxforth@gmail.com> writes:
>> The problem with locals is that if one can justify its use in one
>> function, why not use it everywhere - which has a multiplying effect
>> on performance.
>
> Ok, maybe using locals everywhere slows down the program by 2x. I doubt
> that, but just suppose.

About right for this example

defer moveto ' 2drop is moveto
defer lineto ' 2drop is lineto

: RECT1 { x1 y1 x2 y2 -- }
x1 y1 moveto x2 y1 lineto
x2 y2 lineto x1 y2 lineto x1 y1 lineto ;

: RECT2 ( x1 y1 x2 y2 -- ) \ P.Rubin c.l.f
2over 2dup moveto 2over swap rot lineto
2swap lineto lineto lineto ;

Then there's code size. Return stack we discussed previously.

DX-Forth DTC
RECT1 48 byt
RECT2 27 byt

VFX
RECT1 139/44 byt/instr
RECT2 93/27 byt/instr

Re: Not really locals

<shav7a$qbt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14527&group=comp.lang.forth#14527

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 8 Sep 2021 21:25:44 +0300
Organization: A noiseless patient Spider
Lines: 169
Message-ID: <shav7a$qbt$1@dont-email.me>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 8 Sep 2021 18:25:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="eb6c985476fa4b8074190ac85ec79104";
logging-data="27005"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mgku2StLVwFlaSju3N/8s"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:s5BUBNKIvsXFggvua7mHFPAasOQ=
In-Reply-To: <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
Content-Language: en-US
X-Mozilla-News-Host: news://nntp.aioe.org
 by: Ruvim - Wed, 8 Sep 2021 18:25 UTC

On 2021-09-07 13:12, Hans Bezemer wrote:
[...]

> And easier: if you want to go "easier" the 4tH preprocessor allows you to write code like this:
>
> : calculate ( -- flag)
> let f = f - u;
> let h = h - v;
> let v = (((v + g) * 10) - (u * 2)) / 10;
> let h,|0> 0=|; \ height < 1?
> ;

Nice.

How does the translated code look like? (i.e. after preprocessing)

I can suppose something like "f @ u @ - f !" for "let f = f - u;", and
all variables should be in the scope.

An interesting challenge is to support "ephemeral" immutable local
variables, that are translated into usual stack-based code.

So the following "foo"

: foo ( x1 x2 x3 -- x4 )
let( a b c ){ a a * b b * + c / }
;

is translated to (or at least it's equivalent to):

: foo ( x1 x2 x3 -- x4 )
>r dup * swap dup * + r> /
;

In the construct:

let( <names> ){ <body> }

The code in <body> cannot access the data stack items that were not
placed to the stack by this code. Perhaps, some other restriction
should be also applied.

[...]

> I know things can get tricky when your stack needs to keep track of three elements or more.
> And some routines simply require that many parameters.

If some routine require too much parameters, it a sign to introduce a
state and/or a data structure (i.e., pass many parameters by a single
argument).

> I solved this partially by creating three read-only "registers" on the return stack
> R@, R'@ and R"@. I can even AKA the darn things to keep the source readable.
>
> aka r@ x0
> aka r'@ y0
>
> : circle ( x y radius --)
> swap >r swap >r 1 over - swap 0 ( dp x y R: x0 y0)
>
> begin
> over x0 + over y0 + set_pixel ( x0 + x, y0 + y)
> over x0 swap - over y0 + set_pixel ( x0 - x, y0 + y)
> over x0 + over y0 swap - set_pixel ( x0 + x, y0 - y)
> over x0 swap - over y0 swap - set_pixel ( x0 - x, y0 - y)
> over y0 + over x0 + swap set_pixel ( x0 + y, y0 + x)
> over y0 + over x0 swap - swap set_pixel ( x0 - y, y0 + x)
> over y0 swap - over x0 + swap set_pixel ( x0 + y, y0 - x)
> over y0 swap - over x0 swap - swap set_pixel ( x0 - y, y0 - x)
> ( dp x y R: x0 y0)
> 1+ >r over 0> if 1- r@ over - else r@ then 2* 1+ rot + swap r>
> over over < ( dp x y f R: x0 y0)
> until drop drop drop r> drop r> drop
> ;
>

Why not use the turtle graphics (cursor-based) approach?

> And yes, you still have to keep on thinking and planning. That's Forth. Deal with it.
> https://sourceforge.net/p/forth-4th/wiki/This%20is%20Forth/

In your variant (1) by the link, why don't you use float literals?
I.e., "1e" instead of "1 s>f" ?
And why don't you rely on the separate floating-point stack?

(1)

float array acc

: tamura-kanada ( n -- fpi)
>r 1 s>f 4 s>f f/ acc f!
1 s>f fdup 2 s>f fsqrt f/ fswap ( f: b a)
1 r> over ( 1 n 1)

do ( f: b a)
>r fover fover f+ 2 s>f f/ ( f: b y a')
frot frot fswap fover f* fsqrt ( f: a' y b')
frot frot fover fswap f- fdup f* ( f: b' a' a'-y^2)
r@ s>f f* acc f@ fswap f- acc f! r> 2*
loop drop

f+ fdup f* acc f@ 4 s>f f* f/
;

It's clumsy, to put it mildly.
Please, don't say that it's Forth and we should just deal with it.

I can suggest a better variant.

: fsq ( f: r1 -- r2 ) fdup f* ;
: fsqdist ( f: r1 r2 -- r3 ) f- fsq ;
: fave ( f: r1 r2 -- r3 ) f+ 2e f/ ;
: fmeang ( f: r1 r2 -- r3 ) f* fsqrt ;

: tamura-kanada ( n -- ) ( f: -- pi )
1e \ a0
1e 2e fsqrt f/ \ b0
1e 4e f/ \ c0
{: f:a f:b f:c :}
1e ( F: k0 )
1 max 1 ?do ( F: k )
a a b a b fmeang ->b fave fdup ->a ( F: k a1 a2 )
fsqdist fover f* fnegate c f+ ->c
2e f*
loop fdrop
a b f+ fsq 4e f/ c f/
;

If you want to avoid locals (temporary locals), we can use private
static variables in something like the following way:

colon tamura-kanada ( n -- ) ( f: -- pi )

fprop a
fprop b
fprop c

:body
1e ->a \ a0
1e 2e fsqrt f/ ->b \ b0
1e 4e f/ ->c \ c0
1e ( F: k0 )
1 max 1 ?do ( F: k )
a a b a b fmeang ->b fave fdup ->a ( F: k a1 a2 )
fsqdist fover f* fnegate c f+ ->c
2e f*
loop fdrop
a b f+ fsq 4e f/ c f/
;

--
Ruvim

Re: Not really locals

<49bde7e9-4d57-4bba-aa06-ad3afa0c6268n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14528&group=comp.lang.forth#14528

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5311:: with SMTP id t17mr5035463qtn.364.1631126006192; Wed, 08 Sep 2021 11:33:26 -0700 (PDT)
X-Received: by 2002:a05:620a:4cf:: with SMTP id 15mr4831049qks.316.1631126006051; Wed, 08 Sep 2021 11:33:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 8 Sep 2021 11:33:25 -0700 (PDT)
In-Reply-To: <3a8061a4-11e4-41c5-9b4c-b789d789d73an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.255.113.178; posting-account=OxDKOgoAAADW0cxAqHqpN1zqeCoSsDap
NNTP-Posting-Host: 24.255.113.178
References: <87mtp3ux27.fsf@nightsong.com> <sgf5k8$1h36$1@gioia.aioe.org> <612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com> <2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com> <842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com> <87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org> <87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org> <877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org> <8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org> <87y289q9m7.fsf@nightsong.com> <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com> <87h7ev6832.fsf@nightsong.com> <sh9gfq$ebl$1@gioia.aioe.org> <87y287qy7c.fsf@nightsong.com> <sha988$10fj$1@gioia.aioe.org> <3a8061a4-11e4-41c5-9b4c-b789d789d73an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <49bde7e9-4d57-4bba-aa06-ad3afa0c6268n@googlegroups.com>
Subject: Re: Not really locals
From: hughagui...@gmail.com (Hugh Aguilar)
Injection-Date: Wed, 08 Sep 2021 18:33:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 69
 by: Hugh Aguilar - Wed, 8 Sep 2021 18:33 UTC

On Wednesday, September 8, 2021 at 8:22:30 AM UTC-7, S Jack wrote:
> I roll my eyes when I see "Chuck did it this way", "The Forth Way,
> "Easier to maintain", "Less mistakes", and "Helping the poor newbie".
> There's probably a rhetorical category for such phrases. To me they just
> convey someone's delusional "Do it MY way and the world will be a better
> place."

The problem is that Elizabeth Rather appoints the Forth-200x committee members
and she is absolutely opposed to general-purpose data-structures.
The Forth-200x committee members, such as Anton Ertl, Bernd Paysan and
Stephen Pelc are relentlessly ignorant of general-purpose data-structures because
they are afraid of losing their exulted position in Forth-200x lording over mere
Forth programmers such as myself. They can have the concept of general-purpose
data-structures explained to them one hundred times by the most patient teachers
using the simplest words, and they will continue to steadfastly maintain their ignorance.
The Forth-200x committee members are acting dumb to avoid the Elizabeth Rather's taboo.
Elizabeth Rather created this taboo because she is dumber than a box of hammers;
she is blindly following Charles Moore decades later instead of learning how to program.
She has turned Forth into a haven for people such as DXforth who are equally dumb,
but want to be experts in programming without ever learning anything.

The Forth-200x committee member Peter Knaggs made an attempt at designing
a general-purpose linked-list and he failed completely.
https://groups.google.com/g/comp.lang.forth/c/cMa8wV3OiY0/m/INBDVBh0BgAJ
I said this:
On Saturday, May 18, 2019 at 3:05:23 PM UTC-7, hughag...@gmail.com wrote:
> Why did Peter Knaggs fail so badly at designing a linked-list package?
> He does have a PhD., so you would think that he could succeed at this.
> There are three possible explanations for his failure:
>
> 1.) Peter Knaggs is dumber than a fresh cow-patty on the summit of
> Mount Everest. He couldn't figure out how to implement a linked list.
>
> 2.) Elizabeth Rather told him to design a linked-list package, but
> purposely cripple it. Her goal was that it would be accepted, but then
> nobody would use it because it doesn't work. Then she would say:
> "...in Forth it's so easy to build data structures that are exactly right
> for the particular application at hand that worrying about what pre-built
> structures you have and how to use them is just not worth the bother."
> 3.) Stephen Pelc told him to design a linked-list package, but
> purposely cripple it. His goal was that it would be accepted, but then
> nobody would use it because it doesn't work. Then he would say:
> "If you want a linked-list package that is actually usable,
> you have to buy VFX and get our proprietary package that includes
> such super-duper features as FIND-NODE etc.."

Elizabeth Rather is opposed to general-purpose data-structures because Charles Moore
(note that I don't call him "Chuck" because I'm not pretending to be his buddy boy")
was supposedly opposed. I say "supposedly"because he has been incommunicado for decades
--- ever since he walked out of the ANS-Forth committee and slammed the door behind him.
All of his quotes on the subject of programming style come from prior to when
Elizabeth Rather kicked him out of Forth Inc. in 1982 --- this opposition to
general-purpose data-structures is really an artifact of the 1970s --- and it is not really
"opposition" so much as "ignorance" as the concept was largely unknown in in the 1970s.
This was the era of the 8080 and 6800, prior to the advent of the Z80 and the 6502
--- quite a lot of concepts were unknown in the 1970s (I was in elementary school then).

The C language is also an artifact of the 1970s, and it also fails to support
general-purpose data-structures. C originated for systems programming,
especially the Unix OS, which isn't really similar to application programming.
GCC introduced nested functions that have access to the parent function's
local variables (similar to my rquotations but more complicated because
they can have local variables of their own). GCC presumably borrowed
this idea from Pascal. The C language is stuck with ANSI-C however, that fails
to support general-purpose data-structures. The 1990s were an opportunity for Forth
to pull ahead of ANSI-C and provide rquotations that would have supported
general-purpose data-structures. The ANS-Forth committee, led by Elizabeth Rather,
totally failed to take advantage of this opportunity. What we got instead was
ANS-Forth that was an attempt at turning Forth into ANSI-C with reverse-polish-notation.
ANS-Forth could have revived Forth, but instead nailed the coffin shut!

Re: Not really locals

<87tuiurhbk.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14530&group=comp.lang.forth#14530

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 08 Sep 2021 12:35:43 -0700
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <87tuiurhbk.fsf@nightsong.com>
References: <87mtp3ux27.fsf@nightsong.com> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<87h7ev6832.fsf@nightsong.com> <sh9gfq$ebl$1@gioia.aioe.org>
<87y287qy7c.fsf@nightsong.com> <sha988$10fj$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ac82e9b28adc83a3f5f6ab02d889e17b";
logging-data="22435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bXz2Py7835ThJlKxSdZlV"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:JU2h+4H+58FAjY70aKgyDOAJLdQ=
sha1:nD5v6x25dyDTLkUYIDtW56nE6X8=
 by: Paul Rubin - Wed, 8 Sep 2021 19:35 UTC

dxforth <dxforth@gmail.com> writes:
> 'Forth is a stack-based language' ought to have been clear enough.

I don't know of anyone using Forth on stack hardware these days.
Everyone uses ram hardware. So they might as well use the ram.
I thought one of the ideas of Forth was to utilize the hardware, after
all. The AVR's have 32 registers, a wonderful resource, and you want to
just ignore them?

Re: Not really locals

<87o892rgny.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14531&group=comp.lang.forth#14531

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 08 Sep 2021 12:49:53 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <87o892rgny.fsf@nightsong.com>
References: <87mtp3ux27.fsf@nightsong.com> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<87h7ev6832.fsf@nightsong.com> <sh9gfq$ebl$1@gioia.aioe.org>
<87y287qy7c.fsf@nightsong.com> <shapgj$1a32$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ac82e9b28adc83a3f5f6ab02d889e17b";
logging-data="22435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SXjBJVWr0MgGU0/yrGh8X"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:gFKgqfa/Nl5PwPRHSo8oi3Ed4xQ=
sha1:0NvSHS6sA3nq3ZShsf9Ji7SDfPA=
 by: Paul Rubin - Wed, 8 Sep 2021 19:49 UTC

dxforth <dxforth@gmail.com> writes:
> defer moveto ' 2drop is moveto
> defer lineto ' 2drop is lineto
>
> : RECT1 { x1 y1 x2 y2 -- }
> x1 y1 moveto x2 y1 lineto
> x2 y2 lineto x1 y2 lineto x1 y1 lineto ;

Bytecode compilation:

LOCAL1 LOCAL2 CALL moveto
LOCAL3 LOCAL2 CALL moveto
LOCAL3 LOCAL4 CALL lineto
LOCAL1 LOCAL2 CALL lineto

Bytecodes LOCAL1..LOCAL4 and CALL are 1 byte each, code addresses 2
bytes, total 20 bytes. Actually maybe could use GreenArrays-like
instruction coding (top bit = CALL) to make <CALL address> 2 bytes, so
16 bytes total. That limits code space to 32k, but once you have that
much you're not so hungry for it anyway.

> : RECT2 ( x1 y1 x2 y2 -- ) \ P.Rubin c.l.f
> 2over 2dup moveto 2over swap rot lineto
> 2swap lineto lineto lineto ;

2OVER 2DUP CALL moveto
2OVER SWAP ROT CALL lineto
2SWAP CALL lineto
CALL lineto CALL lineto

6+12=18 or 6+8=14 bytes, not bad, you saved 2 bytes. The code is much
more confusing though. Was it worth it? Probably not imho.

Ephemeral locals (was: Not really locals)

<shb4cg$uao$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14532&group=comp.lang.forth#14532

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Ephemeral locals (was: Not really locals)
Date: Wed, 8 Sep 2021 22:53:50 +0300
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <shb4cg$uao$1@dont-email.me>
References: <87mtp3ux27.fsf@nightsong.com>
<2021Aug27.121151@mips.complang.tuwien.ac.at> <sgf5k8$1h36$1@gioia.aioe.org>
<612bdf5d$0$696$14726298@news.sunsite.dk> <87eea6tyl4.fsf@nightsong.com>
<2021Sep3.120548@mips.complang.tuwien.ac.at> <875yvhtttk.fsf@nightsong.com>
<sgv015$ckc$1@gioia.aioe.org> <87wnnwswj7.fsf@nightsong.com>
<842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com>
<f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<shav7a$qbt$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 8 Sep 2021 19:53:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="eb6c985476fa4b8074190ac85ec79104";
logging-data="31064"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VIVnYJchrjbWcP+CaLdU5"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:kHbSx/rIV5ZhRFVGSQl1r/BCKlw=
In-Reply-To: <shav7a$qbt$1@dont-email.me>
Content-Language: en-US
 by: Ruvim - Wed, 8 Sep 2021 19:53 UTC

On 2021-09-08 21:25, Ruvim wrote:
>
> An interesting challenge is to support "ephemeral" immutable local
> variables, that are translated into usual stack-based code.
>
> So the following "foo"
>
>   : foo ( x1 x2 x3 -- x4 )
>     let( a b c ){ a a *  b b * + c / }
>   ;
>
> is translated to (or at least it's equivalent to):
>
>   : foo ( x1 x2 x3 -- x4 )
>     >r dup * swap dup * + r> /
>   ;
>
>
> In the construct:
>
>   let( <names> ){ <body> }
>
> The code in <body> cannot access the data stack items that were not
> placed to the stack by this code.  Perhaps, some other restriction
> should be also applied.

One hard restriction is that the static stack effect for each word in
<body> should be known. If a static stack effect for neither word
(except "variables" themself) is known, the corresponding actual
variables cannot be avoided in principle.

Concerning the restriction on accessing (consuming) the data stack items
beyond the construct — it's unclear to me whether this restriction is
needed or not.

--
Ruvim

Re: Not really locals

<2021Sep8.221211@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14533&group=comp.lang.forth#14533

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Wed, 08 Sep 2021 20:12:11 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 40
Message-ID: <2021Sep8.221211@mips.complang.tuwien.ac.at>
References: <87mtp3ux27.fsf@nightsong.com> <87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org> <87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org> <877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org> <8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org> <87y289q9m7.fsf@nightsong.com> <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com> <87h7ev6832.fsf@nightsong.com> <sh9gfq$ebl$1@gioia.aioe.org> <87y287qy7c.fsf@nightsong.com> <shapgj$1a32$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="ba95806a9367736e941b1ff3aa8ec260";
logging-data="2210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190NPID3zVW0dRJa7xRei6u"
Cancel-Lock: sha1:EPLLnbWzvaSIEowcW+USfuV/Pz4=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 8 Sep 2021 20:12 UTC

dxforth <dxforth@gmail.com> writes:
>defer moveto ' 2drop is moveto
>defer lineto ' 2drop is lineto
>
>: RECT1 { x1 y1 x2 y2 -- }
> x1 y1 moveto x2 y1 lineto
> x2 y2 lineto x1 y2 lineto x1 y1 lineto ;
>
>: RECT2 ( x1 y1 x2 y2 -- ) \ P.Rubin c.l.f
> 2over 2dup moveto 2over swap rot lineto
> 2swap lineto lineto lineto ;
>
>Then there's code size. Return stack we discussed previously.
>
>DX-Forth DTC
>RECT1 48 byt
>RECT2 27 byt
>
>VFX
>RECT1 139/44 byt/instr
>RECT2 93/27 byt/instr

This time lxf is not doing so great:

RECT1 131 bytes
RECT2 87 bytes

For 64-bit Gforth it is:

RECT1 216 bytes (27 cells) threaded code 321 bytes native code (without ;s)
RECT2 136 bytes (17 cells) threaded code 233 bytes native code (without ;s)

native-code is for gforth-fast.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Not really locals

<df6088a0-587c-448b-bcc5-05f8927954c6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14534&group=comp.lang.forth#14534

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:b6c1:: with SMTP id g184mr349195qkf.270.1631138322606;
Wed, 08 Sep 2021 14:58:42 -0700 (PDT)
X-Received: by 2002:a0c:8064:: with SMTP id 91mr582569qva.66.1631138322487;
Wed, 08 Sep 2021 14:58:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 8 Sep 2021 14:58:42 -0700 (PDT)
In-Reply-To: <sh990n$8nk$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <87mtp3ux27.fsf@nightsong.com> <2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org> <612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com> <2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com> <842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com> <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<b671d481-e94f-4ef8-b79d-6ca03e40b2d6n@googlegroups.com> <sh990n$8nk$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <df6088a0-587c-448b-bcc5-05f8927954c6n@googlegroups.com>
Subject: Re: Not really locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 08 Sep 2021 21:58:42 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 25
 by: Hans Bezemer - Wed, 8 Sep 2021 21:58 UTC

On Wednesday, September 8, 2021 at 5:00:42 AM UTC+2, dxforth wrote:
> It exists for its differences.
Exactly my point. It's a mindset. With all these features we obviously crave for - I find writing C code tedius. It takes much longer before I have compilable and testable code. And for some reason or another, writing application code is much faster in Forth than C - in my experience. Forth hardly ever surprises you - like C can.

> Forth with its absurd numbers of small definitions replaces the parameter
> and structure laden, page-long, multi-indented definition approach of other
> languages. Were they the same and appealed to the same people, Forth would
> have no reason to exist.
Exactly my point. All these "features" are better implemented in all these languages that were designed around them. Therefore, why do you want 'em in Forth? Just because you're too lazy to learn it the proper way and still wanna addit to your resume? See mummy, I'm cool, I can write Forth?

I think the best thing of Forth is the mindset it creates. I once started out with a CASE..ENDCASE converter and I ended up with a preprocessor that challenges M4. Existing of hundreds of one liners. I wouldn't even know where to begin writing such a beast in C. In Forth it seems relatively easy..

Hans Bezemer

Re: Not really locals

<7a36e14c-4b9e-446b-90b6-c0ecc1a90779n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14535&group=comp.lang.forth#14535

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:b6c1:: with SMTP id g184mr492816qkf.270.1631140476213;
Wed, 08 Sep 2021 15:34:36 -0700 (PDT)
X-Received: by 2002:a05:620a:294d:: with SMTP id n13mr450171qkp.179.1631140476063;
Wed, 08 Sep 2021 15:34:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 8 Sep 2021 15:34:35 -0700 (PDT)
In-Reply-To: <shav7a$qbt$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <87mtp3ux27.fsf@nightsong.com> <2021Aug27.121151@mips.complang.tuwien.ac.at>
<sgf5k8$1h36$1@gioia.aioe.org> <612bdf5d$0$696$14726298@news.sunsite.dk>
<87eea6tyl4.fsf@nightsong.com> <2021Sep3.120548@mips.complang.tuwien.ac.at>
<875yvhtttk.fsf@nightsong.com> <sgv015$ckc$1@gioia.aioe.org>
<87wnnwswj7.fsf@nightsong.com> <842e2f23-e787-4aa6-a90c-8874891e1d9en@googlegroups.com>
<87o897sn3l.fsf@nightsong.com> <sh1j5u$gdi$1@gioia.aioe.org>
<87k0jvscg0.fsf@nightsong.com> <sh4osq$9sn$1@gioia.aioe.org>
<877dftspq8.fsf@nightsong.com> <sh6f2p$h91$1@gioia.aioe.org>
<8735qhrvla.fsf@nightsong.com> <sh6l4t$ic9$1@gioia.aioe.org>
<87y289q9m7.fsf@nightsong.com> <f8d0fd68-4b05-4e0b-b043-430abed3dfa5n@googlegroups.com>
<shav7a$qbt$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7a36e14c-4b9e-446b-90b6-c0ecc1a90779n@googlegroups.com>
Subject: Re: Not really locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 08 Sep 2021 22:34:36 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 173
 by: Hans Bezemer - Wed, 8 Sep 2021 22:34 UTC

On Wednesday, September 8, 2021 at 8:25:48 PM UTC+2, Ruvim wrote:

I'll keep it short - 4tH is NOT your average Forth compiler. It's quite lightweight with about 500 libs to customize it.
So floats are no built-in. They're extra. And there are two different flavors.

Turtle graphics are also extra. And why would you use these in an efficient, precision circle algorithm?

And yes - like others I've also written code that will punch out stack shuffles after a stack diagram. It's not hard.

The idea of a stack is to eliminate as many variables as possible. That mean local and global variables. I'm always proud if I succeed in that.

And yes, the preprocessor does exactly that when evaluating LET expressions. It's an algorithm - not magic. I'd like to have and give choices. There is not one single right way to do things.

However, I am quite protective of my small core. I don't like bloating it with things someone might not need.

Hans Bezemer

> On 2021-09-07 13:12, Hans Bezemer wrote:
> [...]
> > And easier: if you want to go "easier" the 4tH preprocessor allows you to write code like this:
> >
> > : calculate ( -- flag)
> > let f = f - u;
> > let h = h - v;
> > let v = (((v + g) * 10) - (u * 2)) / 10;
> > let h,|0> 0=|; \ height < 1?
> > ;
> Nice.
>
> How does the translated code look like? (i.e. after preprocessing)
>
> I can suppose something like "f @ u @ - f !" for "let f = f - u;", and
> all variables should be in the scope.
>
>
>
>
> An interesting challenge is to support "ephemeral" immutable local
> variables, that are translated into usual stack-based code.
>
> So the following "foo"
>
> : foo ( x1 x2 x3 -- x4 )
> let( a b c ){ a a * b b * + c / }
> ;
>
> is translated to (or at least it's equivalent to):
>
> : foo ( x1 x2 x3 -- x4 )
> >r dup * swap dup * + r> /
> ;
>
>
> In the construct:
>
> let( <names> ){ <body> }
>
> The code in <body> cannot access the data stack items that were not
> placed to the stack by this code. Perhaps, some other restriction
> should be also applied.
>
>
>
>
> [...]
> > I know things can get tricky when your stack needs to keep track of three elements or more.
> > And some routines simply require that many parameters.
> If some routine require too much parameters, it a sign to introduce a
> state and/or a data structure (i.e., pass many parameters by a single
> argument).
> > I solved this partially by creating three read-only "registers" on the return stack
> > R@, R'@ and R"@. I can even AKA the darn things to keep the source readable.
> >
> > aka r@ x0
> > aka r'@ y0
> >
> > : circle ( x y radius --)
> > swap >r swap >r 1 over - swap 0 ( dp x y R: x0 y0)
> >
> > begin
> > over x0 + over y0 + set_pixel ( x0 + x, y0 + y)
> > over x0 swap - over y0 + set_pixel ( x0 - x, y0 + y)
> > over x0 + over y0 swap - set_pixel ( x0 + x, y0 - y)
> > over x0 swap - over y0 swap - set_pixel ( x0 - x, y0 - y)
> > over y0 + over x0 + swap set_pixel ( x0 + y, y0 + x)
> > over y0 + over x0 swap - swap set_pixel ( x0 - y, y0 + x)
> > over y0 swap - over x0 + swap set_pixel ( x0 + y, y0 - x)
> > over y0 swap - over x0 swap - swap set_pixel ( x0 - y, y0 - x)
> > ( dp x y R: x0 y0)
> > 1+ >r over 0> if 1- r@ over - else r@ then 2* 1+ rot + swap r>
> > over over < ( dp x y f R: x0 y0)
> > until drop drop drop r> drop r> drop
> > ;
> >
> Why not use the turtle graphics (cursor-based) approach?
> > And yes, you still have to keep on thinking and planning. That's Forth. Deal with it.
> > https://sourceforge.net/p/forth-4th/wiki/This%20is%20Forth/
> In your variant (1) by the link, why don't you use float literals?
> I.e., "1e" instead of "1 s>f" ?
> And why don't you rely on the separate floating-point stack?
>
>
> (1)
>
> float array acc
>
> : tamura-kanada ( n -- fpi)
> >r 1 s>f 4 s>f f/ acc f!
> 1 s>f fdup 2 s>f fsqrt f/ fswap ( f: b a)
> 1 r> over ( 1 n 1)
>
> do ( f: b a)
> >r fover fover f+ 2 s>f f/ ( f: b y a')
> frot frot fswap fover f* fsqrt ( f: a' y b')
> frot frot fover fswap f- fdup f* ( f: b' a' a'-y^2)
> r@ s>f f* acc f@ fswap f- acc f! r> 2*
> loop drop
>
> f+ fdup f* acc f@ 4 s>f f* f/
> ;
>
>
> It's clumsy, to put it mildly.
> Please, don't say that it's Forth and we should just deal with it.
>
>
> I can suggest a better variant.
>
> : fsq ( f: r1 -- r2 ) fdup f* ;
> : fsqdist ( f: r1 r2 -- r3 ) f- fsq ;
> : fave ( f: r1 r2 -- r3 ) f+ 2e f/ ;
> : fmeang ( f: r1 r2 -- r3 ) f* fsqrt ;
>
> : tamura-kanada ( n -- ) ( f: -- pi )
> 1e \ a0
> 1e 2e fsqrt f/ \ b0
> 1e 4e f/ \ c0
> {: f:a f:b f:c :}
> 1e ( F: k0 )
> 1 max 1 ?do ( F: k )
> a a b a b fmeang ->b fave fdup ->a ( F: k a1 a2 )
> fsqdist fover f* fnegate c f+ ->c
> 2e f*
> loop fdrop
> a b f+ fsq 4e f/ c f/
> ;
>
>
> If you want to avoid locals (temporary locals), we can use private
> static variables in something like the following way:
>
> colon tamura-kanada ( n -- ) ( f: -- pi )
>
> fprop a
> fprop b
> fprop c
>
> :body
> 1e ->a \ a0
> 1e 2e fsqrt f/ ->b \ b0
> 1e 4e f/ ->c \ c0
> 1e ( F: k0 )
> 1 max 1 ?do ( F: k )
> a a b a b fmeang ->b fave fdup ->a ( F: k a1 a2 )
> fsqdist fover f* fnegate c f+ ->c
> 2e f*
> loop fdrop
> a b f+ fsq 4e f/ c f/
> ;
>
>
>
> --
> Ruvim

Pages:1234567
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor