Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Life is difficult because it is non-linear.


devel / comp.lang.forth / Re: Another example of factoring and locals

SubjectAuthor
* Another example of factoring and localsAnton Ertl
`* Re: Another example of factoring and localsdxforth
 `* Re: Another example of factoring and localsAnton Ertl
  `* Re: Another example of factoring and localsdxforth
   `* Re: Another example of factoring and localsHans Bezemer
    `* Re: Another example of factoring and localsAnton Ertl
     `* Re: Another example of factoring and localsdxforth
      +* Re: Another example of factoring and localsPaul Rubin
      |+* Re: Another example of factoring and localsminf...@arcor.de
      ||+* Re: Another example of factoring and localsHans Bezemer
      |||+* Re: Another example of factoring and localsPaul Rubin
      ||||`* Re: Another example of factoring and localsdxforth
      |||| `* Re: Another example of factoring and localsPaul Rubin
      ||||  `* Re: Another example of factoring and localsdxforth
      ||||   `* Re: Another example of factoring and localsPaul Rubin
      ||||    +* Re: Another example of factoring and localsdxforth
      ||||    |+* Re: Another example of factoring and localsMarcel Hendrix
      ||||    ||`* Re: Another example of factoring and localsPaul Rubin
      ||||    || `* Re: Another example of factoring and localsdxforth
      ||||    ||  `- Re: Another example of factoring and localsMarcel Hendrix
      ||||    |+* Re: Another example of factoring and localsS Jack
      ||||    ||`- Re: Another example of factoring and localsdxforth
      ||||    |`* Re: Another example of factoring and localsPaul Rubin
      ||||    | +* Re: Another example of factoring and localsdxforth
      ||||    | |+* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||+* Re: Another example of factoring and localsDoug Hoffman
      ||||    | |||+* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||+- Re: Another example of factoring and localsnone
      ||||    | ||||`* Re: Another example of factoring and localsDoug Hoffman
      ||||    | |||| +- Re: Another example of factoring and localsminf...@arcor.de
      ||||    | |||| +- Re: Another example of factoring and localsdxforth
      ||||    | |||| `* Re: Another example of factoring and localsdxforth
      ||||    | ||||  `* Re: Another example of factoring and localsDoug Hoffman
      ||||    | ||||   `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    +- Re: Another example of factoring and localsHans Bezemer
      ||||    | ||||    +- Re: Another example of factoring and localsBrian Fox
      ||||    | ||||    +* Re: Another example of factoring and localsDoug Hoffman
      ||||    | ||||    |`* Re: Another example of factoring and localsdxforth
      ||||    | ||||    | `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |  `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |   `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |    `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |     `* Re: Another example of factoring and localsMarcel Hendrix
      ||||    | ||||    |      `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |       `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |        `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |         `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |          `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |           +* Re: Another example of factoring and localsMarcel Hendrix
      ||||    | ||||    |           |+- Re: Another example of factoring and localsdxforth
      ||||    | ||||    |           |`- Re: Another example of factoring and localsdxforth
      ||||    | ||||    |           `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |            +* Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            |`* Re: Another example of factoring and localsMarcel Hendrix
      ||||    | ||||    |            | +- Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            | +- Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            | `* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |  +* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |            |  |+* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |  ||`* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |            |  || `- Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |  |`* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |  | +- Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |  | `* Re: Another example of factoring and localsHans Bezemer
      ||||    | ||||    |            |  |  `* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |  |   `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |            |  |    `- Re: Another example of factoring and localsdave thompson 2
      ||||    | ||||    |            |  `* Re: Another example of factoring and localsMarcel Hendrix
      ||||    | ||||    |            |   `* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |    `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |            |     +- Re: Another example of factoring and localsnone
      ||||    | ||||    |            |     `- Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            +* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |+- Re: Another example of factoring and localsnone
      ||||    | ||||    |            |`- Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            +- Re: Another example of factoring and localsnone
      ||||    | ||||    |            +* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |+- Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            |`* Re: Another example of factoring and localsHans Bezemer
      ||||    | ||||    |            | `* Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            |  +* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |  |`* Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            |  | +* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |            |  | |+- Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            |  | |`- Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |  | `* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |  |  `- Re: Another example of factoring and localsminf...@arcor.de
      ||||    | ||||    |            |  `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |   `* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |    `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |     `* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |      +* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |      |`* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |      | `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |      |  +* Re: Another example of factoring and localsMarcel Hendrix
      ||||    | ||||    |            |      |  |`- Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |      |  +* Re: Another example of factoring and localsAnton Ertl
      ||||    | ||||    |            |      |  |`* Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |      |  | `* Re: Another example of factoring and localsnone
      ||||    | ||||    |            |      |  |  `- Re: Another example of factoring and localsdxforth
      ||||    | ||||    |            |      |  `* Re: Another example of factoring and localsPaul Rubin
      ||||    | ||||    |            |      `* Re: Another example of factoring and localsnone
      ||||    | ||||    |            +* Re: Another example of factoring and localsLars Brinkhoff
      ||||    | ||||    |            `* Re: Another example of factoring and localsdxforth
      ||||    | ||||    +- Re: Another example of factoring and localsHans Bezemer
      ||||    | ||||    +* Re: Another example of factoring and localsMarcel Hendrix
      ||||    | ||||    +- Re: Another example of factoring and localsHans Bezemer
      ||||    | ||||    +- Re: Another example of factoring and localsP Falth
      ||||    | ||||    `- Re: Another example of factoring and localsminf...@arcor.de
      ||||    | |||`* Re: Another example of factoring and localsHans Bezemer
      ||||    | ||+- Re: Another example of factoring and localsdxforth
      ||||    | ||`* Re: Another example of factoring and localsHans Bezemer
      ||||    | |`- Re: Another example of factoring and localsnone
      ||||    | +- Re: Another example of factoring and localsStephen Pelc
      ||||    | `* Re: Another example of factoring and localsantispam
      ||||    +- Re: Another example of factoring and localsHans Bezemer
      ||||    `- Re: Another example of factoring and localsHans Bezemer
      |||`* Re: Another example of factoring and localsGerry Jackson
      ||`* Re: Another example of factoring and localsPaul Rubin
      |+- Re: Another example of factoring and localsHans Bezemer
      |`* Re: Another example of factoring and localsdxforth
      `* Re: Another example of factoring and localsHans Bezemer

Pages:123456789
Re: Another example of factoring and locals

<nnd$65747fb1$29447d60@041df92cc12b5157>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com> <87a65c66u4.fsf@nightsong.com>
Subject: Re: Another example of factoring and locals
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$65747fb1$29447d60@041df92cc12b5157>
Organization: KPN B.V.
Date: Mon, 31 Oct 2022 11:25:59 +0100
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 40
Injection-Date: Mon, 31 Oct 2022 11:25:59 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2629
 by: none - Mon, 31 Oct 2022 10:25 UTC

In article <87a65c66u4.fsf@nightsong.com>,
Paul Rubin <no.email@nospam.invalid> wrote:
>Doug Hoffman <dhoffman888@gmail.com> writes:
>>> I also don't see how to implement 2SWAP with just DUP, DROP, OVER.
>> Use the return stack as a "local variable holder"
>> and use ROT and SWAP.
>
>I'm doing by the quote from Chuck Moore about DUP, DROP, and OVER (and
>maybe SWAP) being the only legit stack primitives, so no ROT. He does
>use the return stack in his own code though.

Once strings are introduced as a proper pair (not zero-ended)
you need SPSWAP and PSSWAP for swapping a single and a double.
I can't see Chuck Moore object to that.
I use these preferably, because I (like Chuck) have difficulty
remembering the stack diagram of ROT.
>
>> Truthfully, I don't see much difference between conventional locals
>> and using the return stack for same.
>
>There is no RPICK in standard Forth, so you can't get at the internal
>slots. Moore even frowns on regular PICK. Also, you have to be able to
>pop the locals if the word exits through an exception. (LOCAL) had to
>be added to the standard to allow that, since the VM has to handle the
>unwinding in that situation.

PICK is no use. It does something right though, it leaves parameters
on the data stack instead of copying to un undisclosed location.
I experimented with a frame pointer that marks
a position on the stack and names data items from there with an offset.
This works but I was not convinced to show it here on comp.lang.forth.
(but a one-screener and not invasive.)

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Re: Another example of factoring and locals

<tjoa1h$m24$1@gioia.aioe.org>

  copy mid

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

  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: Another example of factoring and locals
Date: Mon, 31 Oct 2022 22:03:12 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tjoa1h$m24$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tjcuft$1hjp$1@gioia.aioe.org> <2022Oct27.123214@mips.complang.tuwien.ac.at>
<tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com>
<2022Oct27.182441@mips.complang.tuwien.ac.at> <tjg2qm$1lbd$1@gioia.aioe.org>
<87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com>
<74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com>
<12932144-da1b-487b-a46c-1c004c3e872bn@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="22596"; 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:102.0) Gecko/20100101
Thunderbird/102.4.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Mon, 31 Oct 2022 11:03 UTC

On 31/10/2022 7:41 pm, Hans Bezemer wrote:
> On Monday, October 31, 2022 at 3:05:16 AM UTC+1, Paul Rubin wrote:
>>
>> Yes, idiot proofing is always a good goal when programming ;).
> According to both Moore and Dijkstra, idiots shouldn't be programming.

I felt the same way after quashing a bug that randomly deleted files :)

Re: Another example of factoring and locals

<tjocnk$g5ah$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: step...@vfxforth.com (Stephen Pelc)
Newsgroups: comp.lang.forth
Subject: Re: Another example of factoring and locals
Date: Mon, 31 Oct 2022 11:49:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <tjocnk$g5ah$1@dont-email.me>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 31 Oct 2022 11:49:08 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="2851676d7ef6d9b58174968e2348d57a";
logging-data="529745"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wwZGMNkpp7/Se9uzrrVpL"
User-Agent: Usenapp for MacOS
Cancel-Lock: sha1:UNiX8gleVlTK88HoA4XuJSXuEi8=
X-Usenapp: v1.23/l - Full License
 by: Stephen Pelc - Mon, 31 Oct 2022 11:49 UTC

On 31 Oct 2022 at 00:48:55 CET, "Paul Rubin" <no.email@nospam.invalid> wrote:

> In Forth, there are only 3 or so
> "registers" (T, N, and R), and each is special. Why be so vehement that
> a human rather than a machine should be juggling them?

If you consider the whole Forth VM there are rather more:
TOS, NOS, PSP \ T, N, data stack pointer
TOR, RSP \ R, return stack pointer
TOF, FSP \ top of floats, float stack pointer
LP \ local pointer
UP \ user area pointer
For stack underflow checking you need three more. On a modern optimising
Forth.
it's easy to find oneself using six to eight CPU registers for the VM and the
same
again for code generation, and a couple of special purpose registers.

Stephen
--
Stephen Pelc, stephen@vfxforth.com
MicroProcessor Engineering, Ltd. - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, +44 (0)78 0390 3612,
+34 649 662 974
http://www.mpeforth.com - free VFX Forth downloads

Re: Another example of factoring and locals

<c2165d44-c482-4022-a104-38ae6813eb49n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:59cb:0:b0:39a:dbc7:2424 with SMTP id f11-20020ac859cb000000b0039adbc72424mr10850896qtf.304.1667229035188;
Mon, 31 Oct 2022 08:10:35 -0700 (PDT)
X-Received: by 2002:a81:5a86:0:b0:36f:cece:6efd with SMTP id
o128-20020a815a86000000b0036fcece6efdmr13122521ywb.489.1667229034990; Mon, 31
Oct 2022 08:10:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!pasdenom.info!nntpfeed.proxad.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: Mon, 31 Oct 2022 08:10:34 -0700 (PDT)
In-Reply-To: <0413dab6-0f98-48bc-9000-ad27a7f994c6n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:409:8400:1228:94b7:690b:32af:89ab;
posting-account=YrYQiQoAAAB3ECk4vm4OgA6KUu5AcEY0
NNTP-Posting-Host: 2601:409:8400:1228:94b7:690b:32af:89ab
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at> <tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<0413dab6-0f98-48bc-9000-ad27a7f994c6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c2165d44-c482-4022-a104-38ae6813eb49n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: dhoffman...@gmail.com (Doug Hoffman)
Injection-Date: Mon, 31 Oct 2022 15:10:35 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Doug Hoffman - Mon, 31 Oct 2022 15:10 UTC

On Monday, October 31, 2022 at 4:40:09 AM UTC-4, the.bee...@gmail.com wrote:

> > : 2swap ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
> > >r rot rot r> swap rot swap ;
> Really?! Even my computer can do better!
> rot >r rot r>

Thanks for pointing that out Hans.
VFX's optimizer lulled me into thinking that
what I showed was efficient. My bad!

-Doug

Re: Another example of factoring and locals

<b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5c8b:0:b0:39b:ff53:bb57 with SMTP id r11-20020ac85c8b000000b0039bff53bb57mr11021694qta.293.1667230232300;
Mon, 31 Oct 2022 08:30:32 -0700 (PDT)
X-Received: by 2002:a25:aba9:0:b0:6c9:eb26:b782 with SMTP id
v38-20020a25aba9000000b006c9eb26b782mr13503154ybi.166.1667230232028; Mon, 31
Oct 2022 08:30:32 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 31 Oct 2022 08:30:31 -0700 (PDT)
In-Reply-To: <87a65c66u4.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:409:8400:1228:94b7:690b:32af:89ab;
posting-account=YrYQiQoAAAB3ECk4vm4OgA6KUu5AcEY0
NNTP-Posting-Host: 2601:409:8400:1228:94b7:690b:32af:89ab
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at> <tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: dhoffman...@gmail.com (Doug Hoffman)
Injection-Date: Mon, 31 Oct 2022 15:30:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3543
 by: Doug Hoffman - Mon, 31 Oct 2022 15:30 UTC

On Sunday, October 30, 2022 at 10:54:29 PM UTC-4, Paul Rubin wrote:
> Doug Hoffman <dhoff...@gmail.com> writes:
> >> I also don't see how to implement 2SWAP with just DUP, DROP, OVER.
> > Use the return stack as a "local variable holder"
> > and use ROT and SWAP.
> I'm doing by the quote from Chuck Moore about DUP, DROP, and OVER (and
> maybe SWAP) being the only legit stack primitives, so no ROT. He does
> use the return stack in his own code though.
> > Truthfully, I don't see much difference between conventional locals
> > and using the return stack for same.
> There is no RPICK in standard Forth, so you can't get at the internal
> slots. Moore even frowns on regular PICK. Also, you have to be able to
> pop the locals if the word exits through an exception. (LOCAL) had to
> be added to the standard to allow that, since the VM has to handle the
> unwinding in that situation.

Meh. What Moore has stated in recent decades also has little to do with
standard Forth.

My point, which I should have stated explicitly, is that detractors of locals
generally say that their use impedes factoring because items are
not on the data stack. But often these same people have no issue
with putting items on the return stack, which must also impede factoring
for the same reason. Though I really don't subscribe to the impede
factoring issue in either case.

Frequently-used core-type words like 2swap should not use locals.
In higher level problem specific words locals have a place in the code I write.

That was fun. What next, a debate about blocks vs text files?

-Doug

Re: Another example of factoring and locals

<18281182-97ae-4cb2-96d9-427f417ca652n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5854:0:b0:39c:dba4:6fa0 with SMTP id h20-20020ac85854000000b0039cdba46fa0mr11374282qth.175.1667231339256;
Mon, 31 Oct 2022 08:48:59 -0700 (PDT)
X-Received: by 2002:a0d:fa45:0:b0:368:5bc3:8db3 with SMTP id
k66-20020a0dfa45000000b003685bc38db3mr13735938ywf.104.1667231339021; Mon, 31
Oct 2022 08:48:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 31 Oct 2022 08:48:58 -0700 (PDT)
In-Reply-To: <tjm5a6$6gt4$3@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at> <tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<tjilf4$3d93q$1@dont-email.me> <b913a769-dfc6-463a-ad06-70a989b844cdn@googlegroups.com>
<tjm5a6$6gt4$3@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <18281182-97ae-4cb2-96d9-427f417ca652n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Mon, 31 Oct 2022 15:48:59 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2653
 by: Hans Bezemer - Mon, 31 Oct 2022 15:48 UTC

On Sunday, October 30, 2022 at 4:30:16 PM UTC+1, Gerry Jackson wrote:
> Sorry about that, I wasn't aware that 4th used zero terminated strings
> and just assumed that standard counted strings were used. So presumably
> your version of COUNT does it by actually counting the characters.
Yes - found out pretty quickly that abstracting STRING words worked in most
situations - so I rarely have problems porting stuff with "cooked" strings.
Unless someone uses COUNT as C@+ equivalent :-(

Note that the overhead of "counting strings" is negligible, since 4tH promotes
the addr/count representation - just like ANS Forth. Only when getting stuff
from string variables or ," compiled strings or +PLACE counting strings is
required.

> It's fortuitous that a 0 byte means an empty string for both ways of
> representing a string.
Yeah - I thought so too! I'm so used to ASCIIZ strings it didn't dawn upon me
this might have been written for COUNTed strings. There I got the idea about
the stack item!

Hans Bezemer

Re: Another example of factoring and locals

<a97629f1-4c4e-4b8f-a3c4-3a5bfc15c3c3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:27c5:b0:4bb:e819:6a5a with SMTP id ge5-20020a05621427c500b004bbe8196a5amr6369312qvb.81.1667232655428;
Mon, 31 Oct 2022 09:10:55 -0700 (PDT)
X-Received: by 2002:a0d:f446:0:b0:34d:4deb:1155 with SMTP id
d67-20020a0df446000000b0034d4deb1155mr13701614ywf.245.1667232655255; Mon, 31
Oct 2022 09:10:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 31 Oct 2022 09:10:55 -0700 (PDT)
In-Reply-To: <b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.157.106.215; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 87.157.106.215
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at> <tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com> <b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a97629f1-4c4e-4b8f-a3c4-3a5bfc15c3c3n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 31 Oct 2022 16:10:55 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3769
 by: minf...@arcor.de - Mon, 31 Oct 2022 16:10 UTC

Doug Hoffman schrieb am Montag, 31. Oktober 2022 um 16:30:33 UTC+1:
> On Sunday, October 30, 2022 at 10:54:29 PM UTC-4, Paul Rubin wrote:
> > Doug Hoffman <dhoff...@gmail.com> writes:
> > >> I also don't see how to implement 2SWAP with just DUP, DROP, OVER.
> > > Use the return stack as a "local variable holder"
> > > and use ROT and SWAP.
> > I'm doing by the quote from Chuck Moore about DUP, DROP, and OVER (and
> > maybe SWAP) being the only legit stack primitives, so no ROT. He does
> > use the return stack in his own code though.
> > > Truthfully, I don't see much difference between conventional locals
> > > and using the return stack for same.
> > There is no RPICK in standard Forth, so you can't get at the internal
> > slots. Moore even frowns on regular PICK. Also, you have to be able to
> > pop the locals if the word exits through an exception. (LOCAL) had to
> > be added to the standard to allow that, since the VM has to handle the
> > unwinding in that situation.
> Meh. What Moore has stated in recent decades also has little to do with
> standard Forth.
>
> My point, which I should have stated explicitly, is that detractors of locals
> generally say that their use impedes factoring because items are
> not on the data stack. But often these same people have no issue
> with putting items on the return stack, which must also impede factoring
> for the same reason. Though I really don't subscribe to the impede
> factoring issue in either case.
>
> Frequently-used core-type words like 2swap should not use locals.
> In higher level problem specific words locals have a place in the code I write.
>
> That was fun. What next, a debate about blocks vs text files?

I'd suggest state-smartness. Seems to attract flies too.

Re: Another example of factoring and locals

<2022Oct31.180940@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Another example of factoring and locals
Date: Mon, 31 Oct 2022 17:09:40 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 46
Message-ID: <2022Oct31.180940@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org> <87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org> <87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org> <87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com> <0413dab6-0f98-48bc-9000-ad27a7f994c6n@googlegroups.com> <c2165d44-c482-4022-a104-38ae6813eb49n@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="94c93f0f09ebac17b7016d6ec75cf17c";
logging-data="578949"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190hUOEJQ5fZa6DpPrLabWO"
Cancel-Lock: sha1:++Z89dl9M5h8aGxnrJ1lijJwhxk=
X-newsreader: xrn 10.11
 by: Anton Ertl - Mon, 31 Oct 2022 17:09 UTC

Doug Hoffman <dhoffman888@gmail.com> writes:
>On Monday, October 31, 2022 at 4:40:09 AM UTC-4, the.bee...@gmail.com wrote:
>
>> > : 2swap ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
>> > >r rot rot r> swap rot swap ;
>> Really?! Even my computer can do better!
>> rot >r rot r>
>
>Thanks for pointing that out Hans.
>VFX's optimizer lulled me into thinking that
>what I showed was efficient. My bad!

Let's see how VFX64 fares:

>r rot rot r> swap rot swap rot >r rot r> 2swap
PUSH RBX PUSH QWORD [RBP+08] MOV RDX, RBX
POP RDX POP RDX MOV RBX, [RBP+08]
MOV RBX, [RBP+08] MOV RCX, [RBP+10] MOV [RBP+08], RDX
MOV [RBP+08], RDX MOV RAX, [RBP] MOV RDX, [RBP+10]
MOV RDX, [RBP+10] MOV [RBP], RCX MOV RCX, [RBP]
MOV RCX, [RBP] MOV [RBP+10], RAX MOV [RBP], RDX
MOV [RBP], RDX MOV [RBP+08], RBX MOV [RBP+10], RCX
MOV [RBP+10], RCX MOV RBX, RDX RET/NEXT
RET/NEXT RET/NEXT 28 Bytes
27 bytes 29 Bytes

For comparison, lxf is analytical about the return stack and compiles
them all to the same code (21 bytes, but 32-bit code rather than
64-bit code):

>r rot rot r> swap rot swap rot >r rot r> 2swap
mov eax , [ebp+4h] mov eax , [ebp+4h] mov eax , [ebp+4h]
mov [ebp+4h] , ebx mov [ebp+4h] , ebx mov [ebp+4h] , ebx
mov ebx , eax mov ebx , eax mov ebx , eax
mov eax , [ebp+8h] mov eax , [ebp+8h] mov eax , [ebp+8h]
mov ecx , [ebp] mov ecx , [ebp] mov ecx , [ebp]
mov [ebp+8h] , ecx mov [ebp+8h] , ecx mov [ebp+8h] , ecx
mov [ebp] , eax mov [ebp] , eax mov [ebp] , eax
ret near ret near ret near

- 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: https://forth-standard.org/
EuroForth 2022: https://euro.theforth.net

Re: Another example of factoring and locals

<2b1b5535-8c74-4b61-b9e5-a00f0ee3c112n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:d806:0:b0:6f1:15cc:d870 with SMTP id u6-20020ae9d806000000b006f115ccd870mr10113600qkf.114.1667237708346;
Mon, 31 Oct 2022 10:35:08 -0700 (PDT)
X-Received: by 2002:a81:71c6:0:b0:36a:5682:2c44 with SMTP id
m189-20020a8171c6000000b0036a56822c44mr13540492ywc.308.1667237708134; Mon, 31
Oct 2022 10:35:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 31 Oct 2022 10:35:07 -0700 (PDT)
In-Reply-To: <2022Oct31.180940@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:8184:b8c3:53b5:cb;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:8184:b8c3:53b5:cb
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <874jvn74e3.fsf@nightsong.com>
<tjic8e$qbm$1@gioia.aioe.org> <87v8o25nhu.fsf@nightsong.com>
<tjklqe$g5m$1@gioia.aioe.org> <87r0yp6fdk.fsf@nightsong.com>
<tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com>
<tjn8al$1ssh$1@gioia.aioe.org> <87eduo694u.fsf@nightsong.com>
<02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com> <0413dab6-0f98-48bc-9000-ad27a7f994c6n@googlegroups.com>
<c2165d44-c482-4022-a104-38ae6813eb49n@googlegroups.com> <2022Oct31.180940@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2b1b5535-8c74-4b61-b9e5-a00f0ee3c112n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Mon, 31 Oct 2022 17:35:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3023
 by: Marcel Hendrix - Mon, 31 Oct 2022 17:35 UTC

On Monday, October 31, 2022 at 6:20:55 PM UTC+1, Anton Ertl wrote:
[..]
> Let's see how VFX64 fares:
>
> >r rot rot r> swap rot swap rot >r rot r> 2swap
[..]
> For comparison, lxf is analytical about the return stack and compiles
> them all to the same code (21 bytes, but 32-bit code rather than
> 64-bit code):
[..]
FORTH> : tt >r rot rot r> swap rot swap rot >r rot r> 2swap ; ok
FORTH> ' tt idis
$0133DC40 : tt
$0133DC4A pop rbx
$0133DC4B pop rdi
$0133DC4C pop rax
$0133DC4D pop rdx
$0133DC4E push rdi
$0133DC4F push rbx
$0133DC50 push rdx
$0133DC51 push rax
$0133DC52 ;
FORTH> : tt2 tt 2swap 2swap 2swap .S ; ok
FORTH> see tt2
Flags: ANSI
$0133DCC0 : tt2
$0133DCCA pop rbx
$0133DCCB pop rdi
$0133DCCC pop rax
$0133DCCD mov rdx, [rsp] qword
$0133DCD1 push rax
$0133DCD2 push rdi
$0133DCD3 push rbx
$0133DCD4 jmp .S+10 ( $012BEA0A ) offset NEAR
$0133DCD9 ;
FORTH> : tt3 1. 2. tt tt tt .S ; ok
FORTH> see tt3
Flags: ANSI
$0133DCC0 : tt3
$0133DCCA push 2 b#
$0133DCCC push 0 b#
$0133DCCE push 1 b#
$0133DCD0 push 0 b#
$0133DCD2 jmp .S+10 ( $012BEA0A ) offset NEAR
$0133DCD7 ;

-marcel

Re: Another example of factoring and locals

<ad9ebf05-aae0-46f6-9cc7-2c4f456db95cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:b351:0:b0:4bc:9ed:6fe6 with SMTP id a17-20020a0cb351000000b004bc09ed6fe6mr2334479qvf.76.1667238323865;
Mon, 31 Oct 2022 10:45:23 -0700 (PDT)
X-Received: by 2002:a25:4a41:0:b0:6cb:dfc2:8856 with SMTP id
x62-20020a254a41000000b006cbdfc28856mr13749322yba.635.1667238323598; Mon, 31
Oct 2022 10:45:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 31 Oct 2022 10:45:23 -0700 (PDT)
In-Reply-To: <2022Oct31.180940@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=95.252.27.40; posting-account=ryzhhAoAAAAIqf1uqmG9E4uP1Bagd-k2
NNTP-Posting-Host: 95.252.27.40
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <874jvn74e3.fsf@nightsong.com>
<tjic8e$qbm$1@gioia.aioe.org> <87v8o25nhu.fsf@nightsong.com>
<tjklqe$g5m$1@gioia.aioe.org> <87r0yp6fdk.fsf@nightsong.com>
<tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com>
<tjn8al$1ssh$1@gioia.aioe.org> <87eduo694u.fsf@nightsong.com>
<02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com> <0413dab6-0f98-48bc-9000-ad27a7f994c6n@googlegroups.com>
<c2165d44-c482-4022-a104-38ae6813eb49n@googlegroups.com> <2022Oct31.180940@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ad9ebf05-aae0-46f6-9cc7-2c4f456db95cn@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: peter.m....@gmail.com (P Falth)
Injection-Date: Mon, 31 Oct 2022 17:45:23 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4147
 by: P Falth - Mon, 31 Oct 2022 17:45 UTC

On Monday, 31 October 2022 at 18:20:55 UTC+1, Anton Ertl wrote:
> Doug Hoffman <dhoff...@gmail.com> writes:
> >On Monday, October 31, 2022 at 4:40:09 AM UTC-4, the.bee...@gmail.com wrote:
> >
> >> > : 2swap ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
> >> > >r rot rot r> swap rot swap ;
> >> Really?! Even my computer can do better!
> >> rot >r rot r>
> >
> >Thanks for pointing that out Hans.
> >VFX's optimizer lulled me into thinking that
> >what I showed was efficient. My bad!
> Let's see how VFX64 fares:
>
> >r rot rot r> swap rot swap rot >r rot r> 2swap
> PUSH RBX PUSH QWORD [RBP+08] MOV RDX, RBX
> POP RDX POP RDX MOV RBX, [RBP+08]
> MOV RBX, [RBP+08] MOV RCX, [RBP+10] MOV [RBP+08], RDX
> MOV [RBP+08], RDX MOV RAX, [RBP] MOV RDX, [RBP+10]
> MOV RDX, [RBP+10] MOV [RBP], RCX MOV RCX, [RBP]
> MOV RCX, [RBP] MOV [RBP+10], RAX MOV [RBP], RDX
> MOV [RBP], RDX MOV [RBP+08], RBX MOV [RBP+10], RCX
> MOV [RBP+10], RCX MOV RBX, RDX RET/NEXT
> RET/NEXT RET/NEXT 28 Bytes
> 27 bytes 29 Bytes
>
> For comparison, lxf is analytical about the return stack and compiles
> them all to the same code (21 bytes, but 32-bit code rather than
> 64-bit code):
>
> >r rot rot r> swap rot swap rot >r rot r> 2swap
> mov eax , [ebp+4h] mov eax , [ebp+4h] mov eax , [ebp+4h]
> mov [ebp+4h] , ebx mov [ebp+4h] , ebx mov [ebp+4h] , ebx
> mov ebx , eax mov ebx , eax mov ebx , eax
> mov eax , [ebp+8h] mov eax , [ebp+8h] mov eax , [ebp+8h]
> mov ecx , [ebp] mov ecx , [ebp] mov ecx , [ebp]
> mov [ebp+8h] , ecx mov [ebp+8h] , ecx mov [ebp+8h] , ecx
> mov [ebp] , eax mov [ebp] , eax mov [ebp] , eax
> ret near ret near ret near

Also the locals version will produce the same code!

: s2 {: a b c d -- c d a b :} c d a b ; ok
see s2
A4A5D4 409CB2 21 C80000 5 normal S2

409CB2 8B4504 mov eax , [ebp+4h]
409CB5 895D04 mov [ebp+4h] , ebx
409CB8 8BD8 mov ebx , eax
409CBA 8B4508 mov eax , [ebp+8h]
409CBD 8B4D00 mov ecx , [ebp]
409CC0 894D08 mov [ebp+8h] , ecx
409CC3 894500 mov [ebp] , eax
409CC6 C3 ret near
ok

Peter

> - 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: https://forth-standard.org/
> EuroForth 2022: https://euro.theforth.net

Re: Another example of factoring and locals

<6c755abb-52c3-4053-890d-1637fa9204b3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:1c85:b0:4af:7393:3d91 with SMTP id ib5-20020a0562141c8500b004af73933d91mr12832391qvb.74.1667247498276;
Mon, 31 Oct 2022 13:18:18 -0700 (PDT)
X-Received: by 2002:a81:500a:0:b0:36c:13d5:b516 with SMTP id
e10-20020a81500a000000b0036c13d5b516mr14711048ywb.70.1667247498103; Mon, 31
Oct 2022 13:18:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 31 Oct 2022 13:18:17 -0700 (PDT)
In-Reply-To: <ad9ebf05-aae0-46f6-9cc7-2c4f456db95cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:8184:b8c3:53b5:cb;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:8184:b8c3:53b5:cb
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <874jvn74e3.fsf@nightsong.com>
<tjic8e$qbm$1@gioia.aioe.org> <87v8o25nhu.fsf@nightsong.com>
<tjklqe$g5m$1@gioia.aioe.org> <87r0yp6fdk.fsf@nightsong.com>
<tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com>
<tjn8al$1ssh$1@gioia.aioe.org> <87eduo694u.fsf@nightsong.com>
<02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com> <0413dab6-0f98-48bc-9000-ad27a7f994c6n@googlegroups.com>
<c2165d44-c482-4022-a104-38ae6813eb49n@googlegroups.com> <2022Oct31.180940@mips.complang.tuwien.ac.at>
<ad9ebf05-aae0-46f6-9cc7-2c4f456db95cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6c755abb-52c3-4053-890d-1637fa9204b3n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Mon, 31 Oct 2022 20:18:18 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2971
 by: Marcel Hendrix - Mon, 31 Oct 2022 20:18 UTC

On Monday, October 31, 2022 at 6:45:25 PM UTC+1, P Falth wrote:
[..]
> Also the locals version will produce the same code!
>
> : s2 {: a b c d -- c d a b :} c d a b ; ok
> see s2
> A4A5D4 409CB2 21 C80000 5 normal S2
>
> 409CB2 8B4504 mov eax , [ebp+4h]
> 409CB5 895D04 mov [ebp+4h] , ebx
> 409CB8 8BD8 mov ebx , eax
> 409CBA 8B4508 mov eax , [ebp+8h]
> 409CBD 8B4D00 mov ecx , [ebp]
> 409CC0 894D08 mov [ebp+8h] , ecx
> 409CC3 894500 mov [ebp] , eax
> 409CC6 C3 ret near

In this particular case I can match that (but not in general).

FORTH> : s2 params| a b c d | c d a b ; ok
FORTH> see s2
Flags: TOKENIZE, ANSI
: s2 (4)PARAMS %c %d %a %b ; ok
FORTH> ' s2 idis
$0133E080 : s2
$0133E08A pop rbx
$0133E08B pop rdi
$0133E08C pop rax
$0133E08D pop rdx
$0133E08E push rdi
$0133E08F push rbx
$0133E090 push rdx
$0133E091 push rax
$0133E092 ;
FORTH> : test 1 2 3 4 s2 .S ; ok
FORTH> see test
Flags: ANSI
$0133E100 : test
$0133E10A push 3 b#
$0133E10C push 4 b#
$0133E10E push 1 b#
$0133E110 push 2 b#
$0133E112 jmp .S+10 ( $012BEA0A ) offset NEAR

-marcel

Re: Another example of factoring and locals

<tjpvls$2rb$1@gioia.aioe.org>

  copy mid

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

  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: Another example of factoring and locals
Date: Tue, 1 Nov 2022 13:18:36 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tjpvls$2rb$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tjcuft$1hjp$1@gioia.aioe.org> <2022Oct27.123214@mips.complang.tuwien.ac.at>
<tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com>
<2022Oct27.182441@mips.complang.tuwien.ac.at> <tjg2qm$1lbd$1@gioia.aioe.org>
<87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com>
<74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com>
<02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com>
<b6d6f67e-d25d-4605-a480-c3c109426092n@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="2923"; 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:102.0) Gecko/20100101
Thunderbird/102.4.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Tue, 1 Nov 2022 02:18 UTC

On 1/11/2022 2:30 am, Doug Hoffman wrote:
>
> What Moore has stated in recent decades also has little to do with
> standard Forth.

He did say the latter "did not describe Forth, but a language with the
same name"! Not sure 'language' is even appropriate - 'unrealized ideal'
would be closer. One would be hard pressed to find a language as drawn-out
and divisive as 'Standard Forth' (any incarnation). If anyone is writing
applications 'in Forth', it's because they've stopped pursuing 'the vision
splendid', accepted what they have, and the short time in which they have
to do it.

Re: Another example of factoring and locals

<tjq4rc$1h03$1@gioia.aioe.org>

  copy mid

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

  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: Another example of factoring and locals
Date: Tue, 1 Nov 2022 14:46:52 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tjq4rc$1h03$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tjcuft$1hjp$1@gioia.aioe.org> <2022Oct27.123214@mips.complang.tuwien.ac.at>
<tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com>
<2022Oct27.182441@mips.complang.tuwien.ac.at> <tjg2qm$1lbd$1@gioia.aioe.org>
<87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com>
<74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com>
<02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com>
<b6d6f67e-d25d-4605-a480-c3c109426092n@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="50179"; 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:102.0) Gecko/20100101
Thunderbird/102.4.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Tue, 1 Nov 2022 03:46 UTC

On 1/11/2022 2:30 am, Doug Hoffman wrote:
>
> My point, which I should have stated explicitly, is that detractors of locals
> generally say that their use impedes factoring because items are
> not on the data stack. But often these same people have no issue
> with putting items on the return stack, which must also impede factoring
> for the same reason.

'These same people' are judicious in their use of return stack. They don't
have so many items that they need to name them, or require the system to
manage it for them :)

Re: Another example of factoring and locals

<19093cee-3054-48ed-8d4a-92c97806589cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:248c:b0:4b8:fbe7:35a0 with SMTP id gi12-20020a056214248c00b004b8fbe735a0mr15473793qvb.75.1667303073667;
Tue, 01 Nov 2022 04:44:33 -0700 (PDT)
X-Received: by 2002:a81:5a86:0:b0:36f:cece:6efd with SMTP id
o128-20020a815a86000000b0036fcece6efdmr16980157ywb.489.1667303073435; Tue, 01
Nov 2022 04:44:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 1 Nov 2022 04:44:33 -0700 (PDT)
In-Reply-To: <tjq4rc$1h03$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:409:8400:1228:94b7:690b:32af:89ab;
posting-account=YrYQiQoAAAB3ECk4vm4OgA6KUu5AcEY0
NNTP-Posting-Host: 2601:409:8400:1228:94b7:690b:32af:89ab
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at> <tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com> <b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>
<tjq4rc$1h03$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <19093cee-3054-48ed-8d4a-92c97806589cn@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: dhoffman...@gmail.com (Doug Hoffman)
Injection-Date: Tue, 01 Nov 2022 11:44:33 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2425
 by: Doug Hoffman - Tue, 1 Nov 2022 11:44 UTC

On Monday, October 31, 2022 at 11:46:55 PM UTC-4, dxforth wrote:

> 'These same people' are judicious in their use of return stack. They don't
> have so many items that they need to name them, or require the system to
> manage it for them :)

Yes. As it should be. I'm a habitual user of the return stack when it is all
I need (as opposed to resorting to locals). Very handy and efficient.

-Doug

Re: Another example of factoring and locals

<tjr6ck$udi$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!NZ87pNe1TKxNDknVl4tZhw.user.46.165.242.91.POSTED!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.forth
Subject: Re: Another example of factoring and locals
Date: Tue, 1 Nov 2022 13:19:16 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tjr6ck$udi$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <2022Oct27.182441@mips.complang.tuwien.ac.at> <tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com> <30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com> <874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org> <87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org> <87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com>
Injection-Info: gioia.aioe.org; logging-data="31154"; posting-host="NZ87pNe1TKxNDknVl4tZhw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (Linux/5.10.0-9-amd64 (x86_64))
Cancel-Lock: sha1:6K8Yjt2sZ2FBVvs9eDXukUxP3pA=
X-Notice: Filtered by postfilter v. 0.9.2
 by: antis...@math.uni.wroc.pl - Tue, 1 Nov 2022 13:19 UTC

Paul Rubin <no.email@nospam.invalid> wrote:
> dxforth <dxforth@gmail.com> writes:
> > It appears he [Moore] found them superfluous:
> > "The words that manipulate that stack are DUP, DROP and OVER
> > period. There's no ..., well SWAP is very convenient and you want it,
> > but it isn't a machine instruction. But no PICK no ROLL, none of the
> > complex operators to let you index down into the stack."
>
> PICK and ROLL have to have come from somewhere: if it wasn't Moore, then
> who? And what about ROT, -ROT, >R, and R>?
>
> I get that Moore used VARIABLEs for everything that I'd use locals for.
> He also used CODE when Forth got in the way too much.
>
> Back in the 1970s, computers were limited, programs were necessarily
> small, and Moore espoused rewriting programs from the ground up instead
> of maintaining them. The main problem facing programmers was how to
> make their program implement behaviour X, for whatever X happened to be
> that day. They'd put a lot of effort into coding and testing X, and
> then they were done.
>
> Today, the main problem facing programmers is ensuring the absence of
> behaviours rather than their presence. Writing code is way easier than
> it used to be, because tools are better and computers are faster. But
> maintaining is harder since programs are bigger and have more people
> hacking at them. If you use a VARIABLE to save a temporary value used
> by a word, then anyone modifying that word, when they see that variable,
> now has to check that no other word uses the variable and depends on it
> for communication. Or worse, communicates through the memory cell
> occupied by that variable but through some sneaky alias. VALUE avoids
> aliasing (no idea whether Moore used them), but locals make both issues
> go away.
>
> Finally, while I can't doubt Moore's genius, I've never understood the
> vision that says the pure stack VM fits every programming problem.
> Register allocation and spilling is one of the messier parts of
> traditional compilers even when there are plenty of registers that don't
> have weird special purposes. In Forth, there are only 3 or so
> "registers" (T, N, and R), and each is special. Why be so vehement that
> a human rather than a machine should be juggling them? I can understand
> taht locals (if supported) complicate the traditional threaded Forth
> interpreter,

I think thatsome voices here vastly overestimate extra complexity.
AFAICS at runtime it is enough to have bunch of extra primitives:
add and subtract from return stack pointer (could be single primitive)
and two primitives fpr each local, one for reading, the other for
storing. If one sticks to standard limit of 16 locals that is 33
primitives. And they are very simple, one or two machine instructions
for real work (plus whatever boilerplate is needed for dispatch).

At compile time main effort is to add new transient part to dictionary.
One needs to decide where to put it. With standard restriction
of local declarations fitting on single line one could use a fixed
size area of order 120-200 bytes. One needs to modify search for
words to look there before main dictionary. And of course one needs
parsing word to recognize locals.

Together that adds some bulk, probably around 500-1000 bytes to
code space and say extra 200 bytes during compile, but I do not
think it is really complication.

> but I don't know how much Moore valued that. I know he did
> like stack hardware (his many Forth chips) but that came later.
>
> So the pure "stack plus VARIABLEs" seems "not even wrong" to me. I
> don't understand the motivation behind it well enough to disagree per
> se. And I've never seen an explanation that made sense. They have all
> seemed like grasping at straws.
>

--
Waldek Hebisch

Re: Another example of factoring and locals

<tjra46$gid$1@gioia.aioe.org>

  copy mid

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

  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: Another example of factoring and locals
Date: Wed, 2 Nov 2022 01:23:02 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tjra46$gid$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tjcuft$1hjp$1@gioia.aioe.org> <2022Oct27.123214@mips.complang.tuwien.ac.at>
<tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com>
<2022Oct27.182441@mips.complang.tuwien.ac.at> <tjg2qm$1lbd$1@gioia.aioe.org>
<87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com>
<74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com>
<02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com>
<b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>
<tjq4rc$1h03$1@gioia.aioe.org>
<19093cee-3054-48ed-8d4a-92c97806589cn@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="16973"; 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:102.0) Gecko/20100101
Thunderbird/102.4.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Tue, 1 Nov 2022 14:23 UTC

On 1/11/2022 10:44 pm, Doug Hoffman wrote:
> On Monday, October 31, 2022 at 11:46:55 PM UTC-4, dxforth wrote:
>
>> 'These same people' are judicious in their use of return stack. They don't
>> have so many items that they need to name them, or require the system to
>> manage it for them :)
>
> Yes. As it should be. I'm a habitual user of the return stack when it is all
> I need (as opposed to resorting to locals). Very handy and efficient.

Are you saying Forth is inadequate - or that it's your choice to extend it
with locals? If Forth is inadequate it would mean I've wasted 40 years on
a bum steer. Locals users too.

Re: Another example of factoring and locals

<671df08f-f157-40a2-ba51-762b99812c1bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:66d1:0:b0:3a5:1bae:cd1a with SMTP id m17-20020ac866d1000000b003a51baecd1amr13328339qtp.625.1667320489460;
Tue, 01 Nov 2022 09:34:49 -0700 (PDT)
X-Received: by 2002:a25:e80d:0:b0:6cb:a59c:541b with SMTP id
k13-20020a25e80d000000b006cba59c541bmr17639901ybd.388.1667320488971; Tue, 01
Nov 2022 09:34:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 1 Nov 2022 09:34:48 -0700 (PDT)
In-Reply-To: <tjr6ck$udi$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:7c0b:7a99:b850:aa46;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:7c0b:7a99:b850:aa46
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjr6ck$udi$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <671df08f-f157-40a2-ba51-762b99812c1bn@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Tue, 01 Nov 2022 16:34:49 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2622
 by: Marcel Hendrix - Tue, 1 Nov 2022 16:34 UTC

On Tuesday, November 1, 2022 at 2:19:21 PM UTC+1, anti...@math.uni.wroc.pl wrote:
[..]
> I think thatsome voices here vastly overestimate extra complexity.
> AFAICS at runtime it is enough to have bunch of extra primitives:
> add and subtract from return stack pointer (could be single primitive)
> and two primitives fpr each local, one for reading, the other for
> storing. If one sticks to standard limit of 16 locals that is 33
> primitives. And they are very simple, one or two machine instructions
> for real work (plus whatever boilerplate is needed for dispatch).

Aren't you forgetting what happens when you call a word that also
uses locals? What about recursion? What happens when bot locals
and the R-stack are used?
>
> At compile time main effort is to add new transient part to dictionary.
[..]

Complexity depends on simply *implementing* locals versus *optimizing* them.
The former is indeed trivially simple.

Another problem: what to do with SEE ?

-marcel

Re: Another example of factoring and locals

<2022Nov1.184932@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Another example of factoring and locals
Date: Tue, 01 Nov 2022 17:49:32 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 48
Message-ID: <2022Nov1.184932@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <87bkpw73fr.fsf@nightsong.com> <30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com> <874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org> <87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org> <87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com> <tjr6ck$udi$1@gioia.aioe.org> <671df08f-f157-40a2-ba51-762b99812c1bn@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="86ef730864fccf5da60622b1b0b35441";
logging-data="879117"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PPLTOuvdDeLYtnKUsOTEy"
Cancel-Lock: sha1:Xe38wFFzbANU6bCdC8Mbauvlmfo=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 1 Nov 2022 17:49 UTC

Marcel Hendrix <mhx@iae.nl> writes:
>On Tuesday, November 1, 2022 at 2:19:21 PM UTC+1, anti...@math.uni.wroc.pl wrote:
>[..]
>> I think thatsome voices here vastly overestimate extra complexity.
>> AFAICS at runtime it is enough to have bunch of extra primitives:
>> add and subtract from return stack pointer (could be single primitive)
>> and two primitives fpr each local, one for reading, the other for
>> storing. If one sticks to standard limit of 16 locals that is 33
>> primitives. And they are very simple, one or two machine instructions
>> for real work (plus whatever boilerplate is needed for dispatch).

Actually, you need only one primitive with an immediate argument N for
reading local N and one primitive with an immediate argument M for
writing local M.

>Aren't you forgetting what happens when you call a word that also
>uses locals? What about recursion?

The locals are on the return stack in his model (like in many
systems), so calls to other words with locals are covered, including
recursion.

>What happens when bot locals
>and the R-stack are used?

The standard has restrictions on mixing that. I think if he wants
minimal complexity, he will also impose these restrictions in programs
on his system (like many systems with locals on the return stack do).

>Another problem: what to do with SEE ?

Most native-code systems show the native code in disassembled form, so
apparently it's not that important that the result of SEE is similar
to the source code. If you want to see that source code, use LOCATE.
In Gforth, SEE shows you the primitives for code generated for locals.
E.g.:

: my2swap {: a b c d :} c d a b ; ok
see my2swap
: my2swap
>l >l >l >l @local2 @local3 @local0 @local1 lp+!# 32 ; ok

- 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: https://forth-standard.org/
EuroForth 2022: https://euro.theforth.net

Re: Another example of factoring and locals

<1e93ffb9-36f7-4954-8db2-d3f907d2dfd4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7d42:0:b0:39c:dd3f:b74d with SMTP id h2-20020ac87d42000000b0039cdd3fb74dmr18653131qtb.279.1667371073479;
Tue, 01 Nov 2022 23:37:53 -0700 (PDT)
X-Received: by 2002:a25:190b:0:b0:6c4:ee7:5ab5 with SMTP id
11-20020a25190b000000b006c40ee75ab5mr21812202ybz.245.1667371073292; Tue, 01
Nov 2022 23:37:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 1 Nov 2022 23:37:53 -0700 (PDT)
In-Reply-To: <tjr6ck$udi$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=87.157.106.215; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 87.157.106.215
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjr6ck$udi$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e93ffb9-36f7-4954-8db2-d3f907d2dfd4n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 02 Nov 2022 06:37:53 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 5543
 by: minf...@arcor.de - Wed, 2 Nov 2022 06:37 UTC

anti...@math.uni.wroc.pl schrieb am Dienstag, 1. November 2022 um 14:19:21 UTC+1:
> Paul Rubin <no.e...@nospam.invalid> wrote:
> > dxforth <dxf...@gmail.com> writes:
> > > It appears he [Moore] found them superfluous:
> > > "The words that manipulate that stack are DUP, DROP and OVER
> > > period. There's no ..., well SWAP is very convenient and you want it,
> > > but it isn't a machine instruction. But no PICK no ROLL, none of the
> > > complex operators to let you index down into the stack."
> >
> > PICK and ROLL have to have come from somewhere: if it wasn't Moore, then
> > who? And what about ROT, -ROT, >R, and R>?
> >
> > I get that Moore used VARIABLEs for everything that I'd use locals for.
> > He also used CODE when Forth got in the way too much.
> >
> > Back in the 1970s, computers were limited, programs were necessarily
> > small, and Moore espoused rewriting programs from the ground up instead
> > of maintaining them. The main problem facing programmers was how to
> > make their program implement behaviour X, for whatever X happened to be
> > that day. They'd put a lot of effort into coding and testing X, and
> > then they were done.
> >
> > Today, the main problem facing programmers is ensuring the absence of
> > behaviours rather than their presence. Writing code is way easier than
> > it used to be, because tools are better and computers are faster. But
> > maintaining is harder since programs are bigger and have more people
> > hacking at them. If you use a VARIABLE to save a temporary value used
> > by a word, then anyone modifying that word, when they see that variable,
> > now has to check that no other word uses the variable and depends on it
> > for communication. Or worse, communicates through the memory cell
> > occupied by that variable but through some sneaky alias. VALUE avoids
> > aliasing (no idea whether Moore used them), but locals make both issues
> > go away.
> >
> > Finally, while I can't doubt Moore's genius, I've never understood the
> > vision that says the pure stack VM fits every programming problem.
> > Register allocation and spilling is one of the messier parts of
> > traditional compilers even when there are plenty of registers that don't
> > have weird special purposes. In Forth, there are only 3 or so
> > "registers" (T, N, and R), and each is special. Why be so vehement that
> > a human rather than a machine should be juggling them? I can understand
> > taht locals (if supported) complicate the traditional threaded Forth
> > interpreter,
> I think thatsome voices here vastly overestimate extra complexity.
> AFAICS at runtime it is enough to have bunch of extra primitives:
> add and subtract from return stack pointer (could be single primitive)
> and two primitives fpr each local, one for reading, the other for
> storing. If one sticks to standard limit of 16 locals that is 33
> primitives. And they are very simple, one or two machine instructions
> for real work (plus whatever boilerplate is needed for dispatch).
>
> At compile time main effort is to add new transient part to dictionary.
> One needs to decide where to put it. With standard restriction
> of local declarations fitting on single line one could use a fixed
> size area of order 120-200 bytes.

With locals declarations in one line you can parse the declarations twice
by resetting >in to {: after first encounter of :}. It makes the locals compiler
only slightly more complex.

Use the the first parsing stage to calculate the required locals frame size
in the return stack. Advantage: the next step for fp, buffer/strings, structure
locals is well prepared.

Locals are seldom worth the effort when one deals only with integers.

FWIW I found string locals very helpful in the past. Very often they can
release you from explicit buffer management or setting up a string stack.

Re: Another example of factoring and locals

<780333d7-0a35-43f5-a923-9bd737e93cf5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:4310:b0:6ac:f9df:178d with SMTP id u16-20020a05620a431000b006acf9df178dmr17193318qko.773.1667384892438;
Wed, 02 Nov 2022 03:28:12 -0700 (PDT)
X-Received: by 2002:a81:5a86:0:b0:36f:cece:6efd with SMTP id
o128-20020a815a86000000b0036fcece6efdmr21891491ywb.489.1667384892158; Wed, 02
Nov 2022 03:28:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Nov 2022 03:28:11 -0700 (PDT)
In-Reply-To: <tjr6ck$udi$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjr6ck$udi$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <780333d7-0a35-43f5-a923-9bd737e93cf5n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 02 Nov 2022 10:28:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2566
 by: Hans Bezemer - Wed, 2 Nov 2022 10:28 UTC

On Tuesday, November 1, 2022 at 2:19:21 PM UTC+1, anti...@math.uni.wroc.pl wrote:
> I think that some voices here vastly overestimate extra complexity.
I did locals in my uBASIC interpreter - because it's BASIC - a Fortran
derivative - it's fitting. But it requires setting up and releasing a stack frame,
copying values there - that's a whole lot of overhead. For some ugly C-ism.
As if we didn't have enough of those in ANS Forth.

> AFAICS at runtime it is enough to have bunch of extra primitives:
> add and subtract from return stack pointer (could be single primitive)
> and two primitives fpr each local, one for reading, the other for
> storing. If one sticks to standard limit of 16 locals that is 33
> primitives. And they are very simple, one or two machine instructions
> for real work (plus whatever boilerplate is needed for dispatch).
33 primitives? And you call that "minor overhead"? My entire VM has about
100 primitives.

Hans Bezemer

Re: Another example of factoring and locals

<71cceea7-10be-4c03-8adc-4190b220dc32n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:4310:b0:6ac:f9df:178d with SMTP id u16-20020a05620a431000b006acf9df178dmr17292330qko.773.1667387097581;
Wed, 02 Nov 2022 04:04:57 -0700 (PDT)
X-Received: by 2002:a81:c11:0:b0:36a:bcf0:6340 with SMTP id
17-20020a810c11000000b0036abcf06340mr22252290ywm.467.1667387097303; Wed, 02
Nov 2022 04:04:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Nov 2022 04:04:56 -0700 (PDT)
In-Reply-To: <tjra46$gid$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at> <tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com> <b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>
<tjq4rc$1h03$1@gioia.aioe.org> <19093cee-3054-48ed-8d4a-92c97806589cn@googlegroups.com>
<tjra46$gid$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <71cceea7-10be-4c03-8adc-4190b220dc32n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 02 Nov 2022 11:04:57 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2820
 by: Hans Bezemer - Wed, 2 Nov 2022 11:04 UTC

On Tuesday, November 1, 2022 at 3:23:07 PM UTC+1, dxforth wrote:
> Are you saying Forth is inadequate - or that it's your choice to extend it
> with locals? If Forth is inadequate it would mean I've wasted 40 years on
> a bum steer. Locals users too.
True. Thinking about programming in a Forth way has significantly influenced my
C style. Now I need to go the opposite way: translating C to Forth, so I can
have loads of local variables - and write functions (not words) of five pages
without ever posing the question: "Do I really need those - or can I do something
clever to eradicate them?"

See: https://sourceforge.net/p/forth-4th/wiki/This%20is%20Forth/ and
https://sourceforge.net/p/forth-4th/wiki/Understand%20your%20algorithm/

Hans Bezemer

Re: Another example of factoring and locals

<6d566723-aba6-477c-987a-5382b2ecc6b1n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:4e53:0:b0:3a5:a2:3461 with SMTP id e19-20020ac84e53000000b003a500a23461mr20009247qtw.490.1667397214741;
Wed, 02 Nov 2022 06:53:34 -0700 (PDT)
X-Received: by 2002:a25:4a41:0:b0:6cb:dfc2:8856 with SMTP id
x62-20020a254a41000000b006cbdfc28856mr23027481yba.635.1667397214415; Wed, 02
Nov 2022 06:53:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Nov 2022 06:53:34 -0700 (PDT)
In-Reply-To: <71cceea7-10be-4c03-8adc-4190b220dc32n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=99.242.210.36; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 99.242.210.36
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at> <tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com> <2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com>
<874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org>
<87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org>
<87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org>
<87ilk06ffc.fsf@nightsong.com> <tjn8al$1ssh$1@gioia.aioe.org>
<87eduo694u.fsf@nightsong.com> <02026cae-ed9d-4708-9e42-064868654c91n@googlegroups.com>
<87a65c66u4.fsf@nightsong.com> <b6d6f67e-d25d-4605-a480-c3c109426092n@googlegroups.com>
<tjq4rc$1h03$1@gioia.aioe.org> <19093cee-3054-48ed-8d4a-92c97806589cn@googlegroups.com>
<tjra46$gid$1@gioia.aioe.org> <71cceea7-10be-4c03-8adc-4190b220dc32n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6d566723-aba6-477c-987a-5382b2ecc6b1n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Wed, 02 Nov 2022 13:53:34 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3199
 by: Brian Fox - Wed, 2 Nov 2022 13:53 UTC

On Wednesday, November 2, 2022 at 7:04:58 AM UTC-4, the.bee...@gmail.com wrote:
> On Tuesday, November 1, 2022 at 3:23:07 PM UTC+1, dxforth wrote:
> > Are you saying Forth is inadequate - or that it's your choice to extend it
> > with locals? If Forth is inadequate it would mean I've wasted 40 years on
> > a bum steer. Locals users too.
> True. Thinking about programming in a Forth way has significantly influenced my
> C style. Now I need to go the opposite way: translating C to Forth, so I can
> have loads of local variables - and write functions (not words) of five pages
> without ever posing the question: "Do I really need those - or can I do something
> clever to eradicate them?"
>
> See: https://sourceforge.net/p/forth-4th/wiki/This%20is%20Forth/ and
> https://sourceforge.net/p/forth-4th/wiki/Understand%20your%20algorithm/
>
> Hans Bezemer

Off topic but ever since you started making videos I can't read your
written stuff without hearing your voice in my head. :-)))
(with the interesting "Nederlandse" accent of course)

Re: Another example of factoring and locals

<87wn8d0z9g.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Another example of factoring and locals
Date: Wed, 02 Nov 2022 15:26:03 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <87wn8d0z9g.fsf@nightsong.com>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tjcuft$1hjp$1@gioia.aioe.org>
<2022Oct27.123214@mips.complang.tuwien.ac.at>
<tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com>
<2022Oct27.182441@mips.complang.tuwien.ac.at>
<tjg2qm$1lbd$1@gioia.aioe.org> <87bkpw73fr.fsf@nightsong.com>
<tji5tj$13t5$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="a4c277599db1974944373a50bcd7f45b";
logging-data="1335349"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19aGOrxsspqK3qWn9Sx7p93"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:8tUVbBwRQYE1ph7E0jmfRBK352w=
sha1:6oDJeqiU/GbKOI4sepU7y6yWAuY=
 by: Paul Rubin - Wed, 2 Nov 2022 22:26 UTC

dxforth <dxforth@gmail.com> writes:
> Oh, I'm not advocating variables - locals or otherwise. What I see is a lot
> of promiscuous use of the former as if there were no cost. Here's an example
> of using extra locals - not out of necessity - but 'style':
>
> https://gforth.org/manual/Locals-programming-style.html

In that example, there is some stuff in locals, but getting rid of the
locals would mean keeping the same stuff on the data stack (and maybe
partly the return stack). The total memory used is the same. In some
systems the return (or locals) stack might be too small, but if you're
going to use locals (or anything else) at all, obviously you want to
size the stacks to accomodate your usage.

> If anyone is writing applications 'in Forth', it's because they've
> stopped pursuing 'the vision splendid' ...

Heh, I like that expression. I had to look up its origin, a book from
1913 about some faction in the Anglican church. I will have to look at
the book one of these days. It's the vision itself that I've never
completely understood. I ought to read more of Dr. Ting's "Zen of
Forth" books, I suppose.

Re: Another example of factoring and locals

<tjva23$120s$1@gioia.aioe.org>

  copy mid

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

  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: Another example of factoring and locals
Date: Thu, 3 Nov 2022 13:46:27 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tjva23$120s$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tjcuft$1hjp$1@gioia.aioe.org> <2022Oct27.123214@mips.complang.tuwien.ac.at>
<tjdt15$1s0n$1@gioia.aioe.org>
<df3724de-f372-4c24-8bf4-059962363089n@googlegroups.com>
<2022Oct27.182441@mips.complang.tuwien.ac.at> <tjg2qm$1lbd$1@gioia.aioe.org>
<87bkpw73fr.fsf@nightsong.com> <tji5tj$13t5$1@gioia.aioe.org>
<87wn8d0z9g.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="34844"; 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:102.0) Gecko/20100101
Thunderbird/102.4.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 3 Nov 2022 02:46 UTC

On 3/11/2022 9:26 am, Paul Rubin wrote:
> dxforth <dxforth@gmail.com> writes:
>> Oh, I'm not advocating variables - locals or otherwise. What I see is a lot
>> of promiscuous use of the former as if there were no cost. Here's an example
>> of using extra locals - not out of necessity - but 'style':
>>
>> https://gforth.org/manual/Locals-programming-style.html
>
> In that example, there is some stuff in locals, but getting rid of the
> locals would mean keeping the same stuff on the data stack (and maybe
> partly the return stack). The total memory used is the same. In some
> systems the return (or locals) stack might be too small, but if you're
> going to use locals (or anything else) at all, obviously you want to
> size the stacks to accomodate your usage.

My point was it went from 4 locals to 6 for reasons of style. It may be
C-style to expend resources this way (I wouldn't know) but I doubt it's
Moore's. But back to your comment. You argue the same resources are
being spent (albeit differently apportioned) so it really doesn't matter
whether one is using locals or stack operators. I suspect you are not
alone. But what are implications of using locals in Forth? It's this:
A stack-based language that cannot exist without the help of locals has
failed and therefore does not deserve to exist.

Re: Another example of factoring and locals

<tjvak6$16j4$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!NZ87pNe1TKxNDknVl4tZhw.user.46.165.242.91.POSTED!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.forth
Subject: Re: Another example of factoring and locals
Date: Thu, 3 Nov 2022 02:56:06 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tjvak6$16j4$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <87bkpw73fr.fsf@nightsong.com> <30befe81-28a6-4022-a383-b118dcefc892n@googlegroups.com> <74d9d175-1aea-4eef-9ccd-d2417cd9950bn@googlegroups.com> <874jvn74e3.fsf@nightsong.com> <tjic8e$qbm$1@gioia.aioe.org> <87v8o25nhu.fsf@nightsong.com> <tjklqe$g5m$1@gioia.aioe.org> <87r0yp6fdk.fsf@nightsong.com> <tjl4rl$fmb$1@gioia.aioe.org> <87ilk06ffc.fsf@nightsong.com> <tjr6ck$udi$1@gioia.aioe.org> <671df08f-f157-40a2-ba51-762b99812c1bn@googlegroups.com>
Injection-Info: gioia.aioe.org; logging-data="39524"; posting-host="NZ87pNe1TKxNDknVl4tZhw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (Linux/5.10.0-9-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:eck+6datlMNRPQNC9Nu4cteUavk=
 by: antis...@math.uni.wroc.pl - Thu, 3 Nov 2022 02:56 UTC

Marcel Hendrix <mhx@iae.nl> wrote:
> On Tuesday, November 1, 2022 at 2:19:21 PM UTC+1, anti...@math.uni.wroc.pl wrote:
> [..]
> > I think thatsome voices here vastly overestimate extra complexity.
> > AFAICS at runtime it is enough to have bunch of extra primitives:
> > add and subtract from return stack pointer (could be single primitive)
> > and two primitives fpr each local, one for reading, the other for
> > storing. If one sticks to standard limit of 16 locals that is 33
> > primitives. And they are very simple, one or two machine instructions
> > for real work (plus whatever boilerplate is needed for dispatch).
>
> Aren't you forgetting what happens when you call a word that also
> uses locals? What about recursion? What happens when bot locals
> and the R-stack are used?

Anton answered this.

> >
> > At compile time main effort is to add new transient part to dictionary.
> [..]
>
> Complexity depends on simply *implementing* locals versus *optimizing* them.
> The former is indeed trivially simple.

I have spent some time working on "optimizing" codegen for two stack
VM with locals. I mean input was sequence of Forth-like operations
and codegen produced machine code. AFAICS result was worse than
your Forth. But offender were not locals. In fact, careful
use of local gave best code. One trouble was insufficient stack
tracking, sometimes items were forced on data stack not because
they had to be there, but only because codegen was unable to
track them. Another trouble was too naive register allocator, which
did not do well with temporaries. But if you had small number
of locals it would put them all in registers. And if all temporaries
were immediately put into locals, then computation could do work
in registers and you would get resonably good code. In other
words, one could use locals to tell compiler which things should
go into registers.

If you say that optimizing locals in _your_ Forth takes substantial
effort, then I belive. I know in principle how to write better
register allocator and do not think it is very hard. But existing
code was micro-optimized in many places and is hard to modify.

So, this is not absolute difficulty of solving problem, but rather
trouble with modifying existing program (plus limited time that
I could spent on this). But with different compiler structure
or when starting anew I could do better. And I _know_ that one
can generate pretty efficient code for locals in rather simple
compiler.

--
Waldek Hebisch


devel / comp.lang.forth / Re: Another example of factoring and locals

Pages:123456789
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor