Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

BYTE editors are people who separate the wheat from the chaff, and then carefully print the chaff.


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

<87h6zal5zu.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.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: Mon, 07 Nov 2022 15:06:13 -0800
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <87h6zal5zu.fsf@nightsong.com>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tk2fp3$185b$1@gioia.aioe.org> <878rkq2h4l.fsf@nightsong.com>
<tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com>
<10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com>
<2022Nov7.232424@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="0a841f034441629650aaf931b3e758f1";
logging-data="3882614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WtLYmZ0gjCeT/54mIaSYa"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:h5uz7k5OWIaWuK9TWL/qB6jdYM8=
sha1:utWRAIBRX2cN2bc6F+ZdbeVBkis=
 by: Paul Rubin - Mon, 7 Nov 2022 23:06 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> Chuck Moore's work on Forth is an example that is not only
> comprehensible to others, but has inspired many others to use it,
> adapt it to their needs, extend it, and do their own things with it.
> And it scaled quite well. Thousands of people have used Forth.

Forth itself is useful and inspiring, but when I look at actual Forth
code written by Chuck Moore, maybe it's just me, but I have found it
quite incomprehensible. That basically means cmForth and some of his
GA144 code, so far. I don't know what else is out there.

> It helps to keep both the implementation and the interface simple, it
> does not help to keep the implementation simple at the cost of
> interface complexity.

The Jeff Fox article calls rather for keeping the implementation simple
at all costs. For example, having OKAD work in 6400/4096ths of a
millivolt (or maybe the reciprocal of that) instead of directly in
millivolts. It seems almost like an extreme caricature of what Dick
Gabriel called the New Jersey approach in "Worse Is Better" (
https://www.dreamsongs.com/RiseOfWorseIsBetter.html ). And Gabriel's
description of the New Jersey approach was itself already a caricature.

Re: Another example of factoring and locals

<4e334059-553b-492b-8a31-a2c2ca93096bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5ad1:0:b0:3a4:ffff:8c59 with SMTP id d17-20020ac85ad1000000b003a4ffff8c59mr40539726qtd.57.1667864812051;
Mon, 07 Nov 2022 15:46:52 -0800 (PST)
X-Received: by 2002:a81:c11:0:b0:36a:bcf0:6340 with SMTP id
17-20020a810c11000000b0036abcf06340mr49488064ywm.467.1667864811871; Mon, 07
Nov 2022 15:46:51 -0800 (PST)
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, 7 Nov 2022 15:46:51 -0800 (PST)
In-Reply-To: <2022Nov7.232547@mips.complang.tuwien.ac.at>
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> <878rkq2h4l.fsf@nightsong.com>
<tk512n$1s92$1@gioia.aioe.org> <dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<tkb4qc$1d6b$1@gioia.aioe.org> <4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com>
<38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com> <2022Nov7.232547@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4e334059-553b-492b-8a31-a2c2ca93096bn@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 07 Nov 2022 23:46:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2630
 by: minf...@arcor.de - Mon, 7 Nov 2022 23:46 UTC

Anton Ertl schrieb am Montag, 7. November 2022 um 23:29:52 UTC+1:
> "minf...@arcor.de" <minf...@arcor.de> writes:
> >Modern 64-bit C passes most arguments through CPU registers.
> >Times are a-changing ...
> C calling conventions on 32-bit architectures such as ARM (1985), MIPS
> (1986), SPARC (1986) etc. all pass parameters through registers.
> Given the age and current status of these architectures, I hesitate to
> call them modern.

Yes, the fastcall calling convention offers itself for CPUs having sufficient
numbers of registers.

I wonder if Forth performance could be improved by keeping a larger stack
segment in CPU registers, than by meanwhile classic TOS-only-caching.
AFAIU the bottleneck is bringing the stack to its canonical state, but this
could be reduced by keeping some registers in reserve (top stack segment
"floating" in CPU registers).

In the end, passing top stack segments already through registers would
about eliminate the difference to using locals.

Re: Another example of factoring and locals

<878rkml3ft.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.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: Mon, 07 Nov 2022 16:01:26 -0800
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <878rkml3ft.fsf@nightsong.com>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<878rkq2h4l.fsf@nightsong.com> <tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<tkb4qc$1d6b$1@gioia.aioe.org>
<4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com>
<38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com>
<2022Nov7.232547@mips.complang.tuwien.ac.at>
<4e334059-553b-492b-8a31-a2c2ca93096bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="0a841f034441629650aaf931b3e758f1";
logging-data="3882614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+P3wEaWOEBz9yRui93xYbP"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:QK6U+i1qWWgULCniyUExo1EuRYo=
sha1:s+sd2Rn6RnV2LTR6ZkblEFFVrs4=
 by: Paul Rubin - Tue, 8 Nov 2022 00:01 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
> I wonder if Forth performance could be improved by keeping a larger
> stack segment in CPU registers, than by meanwhile classic
> TOS-only-caching.

TOS+NOS is also a thing. Mecrisp keeps more stack slots in registers
but has an actual register allocator, so maybe you meant something
simpler.

> AFAIU the bottleneck is bringing the stack to its canonical state, but
> this could be reduced by keeping some registers in reserve (top stack
> segment "floating" in CPU registers).

Mecrisp has some code for tidying the stack like that, but I thought it
was because the word being compiled didn't know where it was being
called from, so it had to present a consistent stack picture wherever
the caller was.

In the case where the compiler knows there is only one call site, the
word can be inlined. If there is more than one call site, but they are
known (say there are 3 of them), I wonder if it's feasible to allocate
the registers so that the shared stack slots all end up in the same
registers.

> In the end, passing top stack segments already through registers would
> about eliminate the difference to using locals.

Once the compiler is that fancy, putting locals in registers seems
natural.

Ditzel's original CRISP cpu had a stack cache that may have been almost
as good as registers. I wonder if something that could come back someday.

Re: Another example of factoring and locals

<tkc82v$1frk$1@gioia.aioe.org>

  copy mid

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

  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, 8 Nov 2022 11:32:30 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tkc82v$1frk$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<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>
<5a98a33e-8eed-402a-92d5-183705a7f1d4n@googlegroups.com>
<tk26jf$h8o$1@gioia.aioe.org> <87leor2s9i.fsf@nightsong.com>
<tk2fp3$185b$1@gioia.aioe.org> <878rkq2h4l.fsf@nightsong.com>
<tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<tkb4qc$1d6b$1@gioia.aioe.org>
<4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com>
<38b67865-7dde-4c69-9abd-8e101af76039n@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="49012"; 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, 8 Nov 2022 00:32 UTC

On 8/11/2022 4:06 am, minf...@arcor.de wrote:
> the.bee...@gmail.com schrieb am Montag, 7. November 2022 um 17:01:21 UTC+1:
>> However, it's alien to the very concept of C, which uses stack frames
>> as its primary data flow mechanism.
>
> Modern 64-bit C passes most arguments through CPU registers.
> Times are a-changing ...

Forth and C VM's know nothing about that. See MPE's 'Programming Forth'.

Jeff remarked locals-in-Forth users would come up with all sorts of
rationalizations for doing so, and that's certainly been true.

"Don't use local variables. Don't come up with new syntaxs for describing
them and new schemes for implementing them. You can make local variables
very efficient especially if you have local registers to store them in,
but don't. It's bad. It's wrong." - C.M.

Re: Another example of factoring and locals

<tkcdmi$15rk$1@gioia.aioe.org>

  copy mid

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

  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, 8 Nov 2022 13:08:18 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tkcdmi$15rk$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tk2fp3$185b$1@gioia.aioe.org> <878rkq2h4l.fsf@nightsong.com>
<tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com>
<10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com>
<2022Nov7.232424@mips.complang.tuwien.ac.at> <87h6zal5zu.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="38772"; 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, 8 Nov 2022 02:08 UTC

On 8/11/2022 10:06 am, Paul Rubin wrote:
> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Chuck Moore's work on Forth is an example that is not only
>> comprehensible to others, but has inspired many others to use it,
>> adapt it to their needs, extend it, and do their own things with it.
>> And it scaled quite well. Thousands of people have used Forth.
>
> Forth itself is useful and inspiring, but when I look at actual Forth
> code written by Chuck Moore, maybe it's just me, but I have found it
> quite incomprehensible. That basically means cmForth and some of his
> GA144 code, so far.

Perhaps because you haven't worked your way up to it. Well, neither have
I - mainly due to lack of motivation.

> I don't know what else is out there.

There's plenty of forth code about which demonstrates locals are rarely,
if ever, needed - and it didn't require a Moore or Fox to do it. If
dismissing all and focussing on the exceptions that is the game, then who
is the one being pure and perfect?

Re: Another example of factoring and locals

<4b98fe84-2e7a-4f07-b0dd-2342d72057edn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5908:0:b0:3a5:73ac:3d5 with SMTP id 8-20020ac85908000000b003a573ac03d5mr13935713qty.457.1667888030603;
Mon, 07 Nov 2022 22:13:50 -0800 (PST)
X-Received: by 2002:a05:6902:1023:b0:6d1:7280:81c7 with SMTP id
x3-20020a056902102300b006d1728081c7mr26778821ybt.530.1667888030388; Mon, 07
Nov 2022 22:13:50 -0800 (PST)
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: Mon, 7 Nov 2022 22:13:50 -0800 (PST)
In-Reply-To: <2022Nov7.232424@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:f999:64ac:81f4:9849;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:f999:64ac:81f4:9849
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tk2fp3$185b$1@gioia.aioe.org>
<878rkq2h4l.fsf@nightsong.com> <tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com> <tk5gv2$1thj$1@gioia.aioe.org>
<874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org>
<87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org>
<87r0yf1ilv.fsf@nightsong.com> <6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com>
<10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com> <2022Nov7.232424@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4b98fe84-2e7a-4f07-b0dd-2342d72057edn@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Tue, 08 Nov 2022 06:13:50 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2180
 by: Marcel Hendrix - Tue, 8 Nov 2022 06:13 UTC

On Monday, November 7, 2022 at 11:24:53 PM UTC+1, Anton Ertl wrote:
> Marcel Hendrix <m...@iae.nl> writes:
[..]
> Chuck Moore's work on Forth is an example that is not
> only comprehensible to others, but has inspired many others to use it,
> adapt it to their needs, extend it, and do their own things with it.
> And it scaled quite well. Thousands of people have used Forth.
That is meta-true for Forth as a language concept. But how many
engineers use CM's tools as-is in their daily work?

-marcel

Re: Another example of factoring and locals

<87sfit3o75.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.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: Mon, 07 Nov 2022 23:22:38 -0800
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <87sfit3o75.fsf@nightsong.com>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tk2fp3$185b$1@gioia.aioe.org> <878rkq2h4l.fsf@nightsong.com>
<tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com>
<10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com>
<2022Nov7.232424@mips.complang.tuwien.ac.at>
<87h6zal5zu.fsf@nightsong.com> <tkcdmi$15rk$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="0a841f034441629650aaf931b3e758f1";
logging-data="4061355"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Y19/PKw5XoK9iKr2C4TxS"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:5m92VDqCL3Ti4XUfgDyvZ0SupLA=
sha1:ooZuqcBTyVYMUR6Io+bSAXglABY=
 by: Paul Rubin - Tue, 8 Nov 2022 07:22 UTC

dxforth <dxforth@gmail.com> writes:
> There's plenty of forth code about which demonstrates locals are
> rarely, if ever, needed

Yes, that code shows that stuff can usually or always be done without
locals. I don't doubt that. What I don't understand is what makes a
without-locals version superior to a locals version.

> "Don't use local variables. Don't come up with new syntaxs for
> describing them and new schemes for implementing them. You can make
> local variables very efficient especially if you have local registers
> to store them in, but don't. It's bad. It's wrong." - C.M.

I doubt C.M. was one for faith in authority, and I haven't yet figured
out what is in his mind when he says things like that. Ideas that have
been mentioned:

1. Locals complicate the compiler. Jeff Fox's essay mentions C.M.'s
compiler uses just 1K of code. Adding locals would make it bigger.

2. Locals are less efficient at runtime. They take more cpu cycles.

3. They use more memory, return stack cells or whatever.

4.. Locals interfere with some kind of Forth spirituality at which I
have currently not reached enlightenment. The one true way is
through commune with the Cosmic Stack Machine.

My reactions:

1. Most of us are using bigger compilers already, even non-ANS. For
example, Mecrisp is around 12K. Gforth is bigger still, but it is ANS,
so it has already left the path and doesn't count.

2. Jeff's article is emphatic, it is ok for the code to be slow, or else
he wouldn't disapprove of optimizing compilers so much. Anyway, this is
a trade-off that can be visited on a per-word basis.

3. Ok, running out of memory is a thing in small processors, but it's
best to get something working and then worry about squeezing stack cells
if you have to. Premature optimization and all that.

4. This I have no idea about, but I had thought early on that C.M. saw
Forth as a spiritual relation of Lisp, even though its formalism is
completely different. I see that as being mostly about interactive
development, code executed at compile time, and simple, user-redefinable
syntax, rather than the stack VM per se. So again I don't understand
the issue with locals. There have even been parsing words for infix
syntax written for Forth. Locals have to be pretty minor compared to
that.

Jeff Fox's essay also said to avoid over-abstraction, but then talks
about the pure stack VM, which is itself an abstraction inversion when
run on a register machine.

Re: Another example of factoring and locals

<tkd3ci$1a2t$1@gioia.aioe.org>

  copy mid

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

  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, 8 Nov 2022 19:18:26 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tkd3ci$1a2t$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tk2fp3$185b$1@gioia.aioe.org> <878rkq2h4l.fsf@nightsong.com>
<tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com>
<10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com>
<2022Nov7.232424@mips.complang.tuwien.ac.at> <87h6zal5zu.fsf@nightsong.com>
<tkcdmi$15rk$1@gioia.aioe.org> <87sfit3o75.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="43101"; 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, 8 Nov 2022 08:18 UTC

On 8/11/2022 6:22 pm, Paul Rubin wrote:
> dxforth <dxforth@gmail.com> writes:
>> There's plenty of forth code about which demonstrates locals are
>> rarely, if ever, needed
>
> Yes, that code shows that stuff can usually or always be done without
> locals. I don't doubt that. What I don't understand is what makes a
> without-locals version superior to a locals version.

For the same reason forth texts and teachers encourage you not to use
variables - it stunts your growth as a forth programmer.

Re: Another example of factoring and locals

<15e83be0-a8fd-4fdb-aed5-508b9fd7ab6cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:897:b0:6fa:1bf8:6de with SMTP id b23-20020a05620a089700b006fa1bf806demr34159841qka.537.1667899224523;
Tue, 08 Nov 2022 01:20:24 -0800 (PST)
X-Received: by 2002:a81:1b53:0:b0:373:6185:b72 with SMTP id
b80-20020a811b53000000b0037361850b72mr30816290ywb.104.1667899224315; Tue, 08
Nov 2022 01:20:24 -0800 (PST)
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: Tue, 8 Nov 2022 01:20:24 -0800 (PST)
In-Reply-To: <878rkml3ft.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f14:6b69:a4a2:cef:8f58:d915;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f14:6b69:a4a2:cef:8f58:d915
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <878rkq2h4l.fsf@nightsong.com>
<tk512n$1s92$1@gioia.aioe.org> <dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<tkb4qc$1d6b$1@gioia.aioe.org> <4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com>
<38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com> <2022Nov7.232547@mips.complang.tuwien.ac.at>
<4e334059-553b-492b-8a31-a2c2ca93096bn@googlegroups.com> <878rkml3ft.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <15e83be0-a8fd-4fdb-aed5-508b9fd7ab6cn@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Tue, 08 Nov 2022 09:20:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3113
 by: minf...@arcor.de - Tue, 8 Nov 2022 09:20 UTC

Paul Rubin schrieb am Dienstag, 8. November 2022 um 01:01:29 UTC+1:
> "minf...@arcor.de" <minf...@arcor.de> writes:
> > I wonder if Forth performance could be improved by keeping a larger
> > stack segment in CPU registers, than by meanwhile classic
> > TOS-only-caching.
> TOS+NOS is also a thing. Mecrisp keeps more stack slots in registers
> but has an actual register allocator, so maybe you meant something
> simpler.
> > AFAIU the bottleneck is bringing the stack to its canonical state, but
> > this could be reduced by keeping some registers in reserve (top stack
> > segment "floating" in CPU registers).
> Mecrisp has some code for tidying the stack like that, but I thought it
> was because the word being compiled didn't know where it was being
> called from, so it had to present a consistent stack picture wherever
> the caller was.

Indeed, too many stack states would increase code size and might even
prevent inlining. It seems more a feasible technique for VMs with a limited
number of primitives. During runtime the stack would probably reside
in a CPU cache anyway for fast access.

And, not to forget, the Standard prohibits this kind of optimization, aka
named stack elements. Instead it stipulates that locals must not use the
data stack as storage resource. Seems to have become a bit backwoodish
today.

Re: Another example of factoring and locals

<2022Nov8.103948@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Tue, 08 Nov 2022 09:39:48 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 78
Message-ID: <2022Nov8.103948@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com> <tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com> <6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com> <10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com> <2022Nov7.232424@mips.complang.tuwien.ac.at> <87h6zal5zu.fsf@nightsong.com>
Injection-Info: reader01.eternal-september.org; posting-host="f04e6591f45150ea2e00e274964c1978";
logging-data="4089197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JgDhelhcSeHPoONHiJDcn"
Cancel-Lock: sha1:TtRwTafAAjGUfxPS9pQ1fAYNdPc=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 8 Nov 2022 09:39 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Chuck Moore's work on Forth is an example that is not only
>> comprehensible to others, but has inspired many others to use it,
>> adapt it to their needs, extend it, and do their own things with it.
>> And it scaled quite well. Thousands of people have used Forth.
>
>Forth itself is useful and inspiring, but when I look at actual Forth
>code written by Chuck Moore, maybe it's just me, but I have found it
>quite incomprehensible. That basically means cmForth and some of his
>GA144 code, so far.

I find the cmForth code that includes the shadow screens
<https://github.com/ForthHub/cmFORTH/blob/combined/cmforth.fth> mostly
comprehensible. Of course when he deals with the machine code of his
architecture and uses octal numbers for the instructions without
giving them names first, it's hard to follow, but the shadow screens
allow you to get the gist of it. E.g., (reformatted for fitting in
70-char lines):

\ PACK sets the return bit, if an instruction does not reference
\ the Return stack. Otherwise it compiles a return. It exits
\ from EXIT with POP DROP .
FORTH : PACK ( a n - a) 160257 AND 140201 XOR IF
40 SWAP +! ELSE DROP 100040 , THEN POP DROP ;

>The Jeff Fox article calls rather for keeping the implementation simple
>at all costs. For example, having OKAD work in 6400/4096ths of a
>millivolt (or maybe the reciprocal of that) instead of directly in
>millivolts.

That's a common technique with fixed-point, and to some extent even
with FP. In TeX Knuth uses lengths in terms of 1/65536ths of a point
IIRC.

>It seems almost like an extreme caricature of what Dick
>Gabriel called the New Jersey approach in "Worse Is Better" (
>https://www.dreamsongs.com/RiseOfWorseIsBetter.html ).

Well, of course what Jeff Fox (or dxforth) wrote may misrepresent the
positions of Chuck Moore, although we also get some of his own
writings.

But anyway, in 1971 Chuck Moore and Ken Thompson (Mr. New Jersey
approach) were both working on minicomputers of the time, and Moore
created Forth, and Thompson created Unix. Both Forth and Unix became
successful, with Forth switching to micros when they became powerful
enough, and Unix growing with the minis and switching to micros only
later in the 1980s. This already shows a difference.

When micros grew beyond the size of the minis Forth was originally
designed for, Chuck Moore refused to take advantage of that (in
particular, he advocated 3 chars+length even when memory was no longer
so tight that we could not afford the full length; most of the Forth
community did not follow him in that instance).

Competition sprung up (e.g., Turbo Pascal) that made use of the
additional opportunities to provide a more comfortable experience to
many programmers than Forth. Some of the Forth community jumped over
to using these things, some tried to make good use of the additional
memory (but failed in the Valdocs case), some insisted on the
superiority of the old ways (screens etc.).

Moore went on to design Forth hardware, OKad, Machine Forth, and
ColorForth, all of which were less successful than Forth.

Thompson continued with further research OSs (Plan 9, Inferno), which
did not become products, and the Go language, which is a product, and
seems to be quite successful (certainly more successful than Forth is
these days, and, coming back to Gabriel's paper, probably also more
successful than Common Lisp).

- 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

<2022Nov8.112605@mips.complang.tuwien.ac.at>

  copy mid

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

  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, 08 Nov 2022 10:26:05 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 73
Message-ID: <2022Nov8.112605@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com> <tkb4qc$1d6b$1@gioia.aioe.org> <4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com> <38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com> <2022Nov7.232547@mips.complang.tuwien.ac.at> <4e334059-553b-492b-8a31-a2c2ca93096bn@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="f04e6591f45150ea2e00e274964c1978";
logging-data="4089197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2Y/UPPNnN0yB5ASu49wPS"
Cancel-Lock: sha1:N9KOnvGNdEwMRQl6Xvhiv5rpymg=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 8 Nov 2022 10:26 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
>I wonder if Forth performance could be improved by keeping a larger stack
>segment in CPU registers, than by meanwhile classic TOS-only-caching.

When I last measured it (Figure 7-9 of [ertl&gregg05]), keeping only
one stack item in a register was better than two for single-state
stack caching (the line labeled "n"), and using the state with one
stack item in a register as canonical state was not worse then keeping
more items in a register as canonical state even for multi-state stack
caching (with the reset to the canonical state happening at basic
block boundaries). Of course, things may have changed now: With Intel
and AMD CPUs making register-register moves cost almost nothing, the
additional moves of using a canonical state with more stack items in
registers may cost less than the benefit we get from the possible
reduction in loads and stores.

>AFAIU the bottleneck is bringing the stack to its canonical state, but this
>could be reduced by keeping some registers in reserve (top stack segment
>"floating" in CPU registers).

That's multi-state stack caching, and Gforth has used this for a while
on architectures with enough registers. It does not reset to the
canonical state between primitives in a basic block.

>In the end, passing top stack segments already through registers would
>about eliminate the difference to using locals.

Given a compiler that is analytical about stack items of all stacks
and about locals, and works at the colon definition level (rather than
the basic block level), I expect essentially the same code from
keeping data on the stack or keeping it in locals: they all are mapped
to registers. Now I only have to write such a compiler:-).

@InProceedings{ertl&gregg05,
author = {M. Anton Ertl and David Gregg},
title = {Stack Caching in {Forth}},
crossref = {euroforth05},
pages = {6--15},
url = {http://www.complang.tuwien.ac.at/papers/ertl%26gregg05.ps.gz},
pdfurl = {http://www.complang.tuwien.ac.at/anton/euroforth2005/papers/ertl%26gregg05.pdf},
OPTnote = {not refereed},
abstract = {Stack caching speeds Forth up by keeping stack items
in registers, reducing the number of memory accesses
for stack items. This paper describes our work on
extending Gforth's stack caching implementation to
support more than one register in the canonical
state, and presents timing results for the resulting
Forth system. For single-representation stack
caches, keeping just one stack item in registers is
usually best, and provides speedups up to a factor
of 2.84 over the straight-forward stack
representation. For stack caches with multiple stack
representations, using the one-register
representation as canonical representation is
usually optimal, resulting in an overall speedup of
up to a factor of 3.80 (and up to a factor of 1.53
over single-representation stack caching).}
} @Proceedings{euroforth05,
title = {21st EuroForth Conference},
booktitle = {21st EuroForth Conference},
year = {2005},
key = {EuroForth'05},
editor = {M. Anton Ertl},
url = {http://www.complang.tuwien.ac.at/anton/euroforth2005/papers/proceedings.pdf}
}

- 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

<7d1284d8-f7c1-429d-8c8a-7c662e50bec9n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:5f0a:0:b0:4c2:301d:eb9a with SMTP id fo10-20020ad45f0a000000b004c2301deb9amr19624430qvb.74.1667905865050;
Tue, 08 Nov 2022 03:11:05 -0800 (PST)
X-Received: by 2002:a25:b814:0:b0:6d7:43d5:ed98 with SMTP id
v20-20020a25b814000000b006d743d5ed98mr10305295ybj.104.1667905864871; Tue, 08
Nov 2022 03:11:04 -0800 (PST)
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: Tue, 8 Nov 2022 03:11:04 -0800 (PST)
In-Reply-To: <2022Nov8.112605@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f14:6b69:a4a2:cef:8f58:d915;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f14:6b69:a4a2:cef:8f58:d915
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tk5gv2$1thj$1@gioia.aioe.org>
<874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org>
<87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org>
<87r0yf1ilv.fsf@nightsong.com> <tkb4qc$1d6b$1@gioia.aioe.org>
<4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com> <38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com>
<2022Nov7.232547@mips.complang.tuwien.ac.at> <4e334059-553b-492b-8a31-a2c2ca93096bn@googlegroups.com>
<2022Nov8.112605@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7d1284d8-f7c1-429d-8c8a-7c662e50bec9n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Tue, 08 Nov 2022 11:11:05 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2444
 by: minf...@arcor.de - Tue, 8 Nov 2022 11:11 UTC

Anton Ertl schrieb am Dienstag, 8. November 2022 um 11:44:57 UTC+1:
> Given a compiler that is analytical about stack items of all stacks
> and about locals, and works at the colon definition level (rather than
> the basic block level), I expect essentially the same code from
> keeping data on the stack or keeping it in locals: they all are mapped
> to registers. Now I only have to write such a compiler:-).

:o) this smells a bit of a stack-state dependent JIT colon def. compiler.
Piece of cake.

Peter Fälth demonstrated his system generating the same code with or
without locals using CPU registers. I am not into wild guessing how, or
whether some stack caching is involved or not, but it was impressive.

Re: Another example of factoring and locals

<tkdjaq$bdj$1@gioia.aioe.org>

  copy mid

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

  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, 8 Nov 2022 23:50:35 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tkdjaq$bdj$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com>
<10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com>
<2022Nov7.232424@mips.complang.tuwien.ac.at> <87h6zal5zu.fsf@nightsong.com>
<2022Nov8.103948@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="11699"; 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, 8 Nov 2022 12:50 UTC

On 8/11/2022 8:39 pm, Anton Ertl wrote:
>
> Well, of course what Jeff Fox (or dxforth) wrote may misrepresent the
> positions of Chuck Moore, although we also get some of his own
> writings.

'You can't trust those two, but you can trust the person who sells them
down the river.' Did I interpret that correctly? I wouldn't want to be
accused of misrepresenting you.

Re: Another example of factoring and locals

<2022Nov8.190506@mips.complang.tuwien.ac.at>

  copy mid

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

  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, 08 Nov 2022 18:05:06 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 42
Message-ID: <2022Nov8.190506@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com> <tkb4qc$1d6b$1@gioia.aioe.org> <4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com> <38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com> <2022Nov7.232547@mips.complang.tuwien.ac.at> <4e334059-553b-492b-8a31-a2c2ca93096bn@googlegroups.com> <878rkml3ft.fsf@nightsong.com>
Injection-Info: reader01.eternal-september.org; posting-host="f04e6591f45150ea2e00e274964c1978";
logging-data="4177882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cUKCY5fF6Ec3XE5Ny8zl0"
Cancel-Lock: sha1:l6AgESjJ/jqB+nRn8vxG0dox6jE=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 8 Nov 2022 18:05 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>Mecrisp has some code for tidying the stack like that, but I thought it
>was because the word being compiled didn't know where it was being
>called from, so it had to present a consistent stack picture wherever
>the caller was.

That's a reason for C with its separate compilation or Lisp with its
dynamic binding, but it's no reason for direct calls in Forth. In
Forth the direct caller always knows what it calls. So the compiler
could compile a word such that it expects its inputs in arbitrary
registers, and puts its output in arbitrary registers, with arbitrary
registers destroyed by the word. And it can then compile almost all
direct callers to deal with that interface.

The exception is direct recursion, where the call typically has to be
compiled before the word is compllete and you know the individual
interface. A (not very efficient) way to deal with that is to treat a
recursive call like an indirect call; or you compile the paths with
the recursive calls only after compiling the base case path, then you
fix the interface, then you compile the remaining paths.

For indirect calls (EXECUTE, DEFER), a fixed calling convention is
needed; that can be achieved by providing a wrapper around the
individual interface.

>Ditzel's original CRISP cpu had a stack cache that may have been almost
>as good as registers. I wonder if something that could come back someday.

No. There's a reason why nobody imitated CRISP. Although nowadays we
have hardware that can bypass the actual store->load latency in some
cases when loading from a recently-stored address, reducing the
latency from 5 or so to 1 cycle. Still, this does not happen reliably
enough and it uses load/store unit resources (2 loads and 1 store per
cycle or somesuch vs. 10 register reads and 5 register writes or
somesuch), so using registers is still the way to go.

- 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

<2022Nov8.193406@mips.complang.tuwien.ac.at>

  copy mid

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

  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, 08 Nov 2022 18:34:06 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 14
Message-ID: <2022Nov8.193406@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tk512n$1s92$1@gioia.aioe.org> <dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com> <tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com> <tkb4qc$1d6b$1@gioia.aioe.org> <4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com> <38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com> <tkc82v$1frk$1@gioia.aioe.org>
Injection-Info: reader01.eternal-september.org; posting-host="f04e6591f45150ea2e00e274964c1978";
logging-data="4177882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fTN8qFMd4Jk00fCIE9IDz"
Cancel-Lock: sha1:CPN/MnLF+HBoGn8emgcddmr+F+w=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 8 Nov 2022 18:34 UTC

dxforth <dxforth@gmail.com> writes:
>"Don't use local variables. Don't come up with new syntaxs for describing
> them and new schemes for implementing them. You can make local variables
> very efficient especially if you have local registers to store them in,
> but don't. It's bad. It's wrong." - C.M.

Reference needed.

- 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

<2022Nov8.193506@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Tue, 08 Nov 2022 18:35:06 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 30
Message-ID: <2022Nov8.193506@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com> <6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com> <10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com> <2022Nov7.232424@mips.complang.tuwien.ac.at> <4b98fe84-2e7a-4f07-b0dd-2342d72057edn@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="f04e6591f45150ea2e00e274964c1978";
logging-data="4177882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19B7tC7e/hJc7cDNO963Her"
Cancel-Lock: sha1:Qy9VkmHIvFA+8HfRcmDu+ju9CvA=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 8 Nov 2022 18:35 UTC

Marcel Hendrix <mhx@iae.nl> writes:
>On Monday, November 7, 2022 at 11:24:53 PM UTC+1, Anton Ertl wrote:
>> Marcel Hendrix <m...@iae.nl> writes:
>[..]
>> Chuck Moore's work on Forth is an example that is not
>> only comprehensible to others, but has inspired many others to use it,
>> adapt it to their needs, extend it, and do their own things with it.
>> And it scaled quite well. Thousands of people have used Forth.
>
>That is meta-true for Forth as a language concept. But how many
>engineers use CM's tools as-is in their daily work?

These days, probably not that many. It seems that his Forth systems
after 1978 (cmForth and ColorForth are known to me, are there others)
were not very popular. But in any case, if his old (1971-1978) Forth
had been incomprehensible, Forth would not have seen the takeup it has
seen. Dean Sanderson would have been unable to design microForth,
Seltzer and Ragsdale would have been unable to do fig-Forth, and so
on.

And I think that given Chuck Moores stance on on rewriting code and
adapting it for the purpose at hand, he considers the concepts more
valuable than the code.

- 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

<87o7th2qyc.fsf@nightsong.com>

  copy mid

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

  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: Tue, 08 Nov 2022 11:20:43 -0800
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <87o7th2qyc.fsf@nightsong.com>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com>
<10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com>
<2022Nov7.232424@mips.complang.tuwien.ac.at>
<4b98fe84-2e7a-4f07-b0dd-2342d72057edn@googlegroups.com>
<2022Nov8.193506@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="0a841f034441629650aaf931b3e758f1";
logging-data="4184378"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SL5na1Z4H7kV65yrXNyvf"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:YWTmDbxQqIi+c/1QKFHqh5ZZuiA=
sha1:7/FV1IFNXgcMm1nLScAJaV64qwM=
 by: Paul Rubin - Tue, 8 Nov 2022 19:20 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> if [C.M.'s] old (1971-1978) Forth had been incomprehensible, Forth
> would not have seen the takeup it has seen. Dean Sanderson would have
> been unable to design microForth, Seltzer and Ragsdale would have been
> unable to do fig-Forth, and so on... And I think ... [C.M.]
> considers the concepts more valuable than the code.

Did Sanderson etc. do their implementations by studying C.M.'s source
code, or did they simply reimplement its behaviour? I find Forth's
concepts to be mostly understandable. What I found hard to understand
was the actual Forth code written by C.M. that I looked at. I also
found fig-Forth to be hard to understand, if that matters. I'm
unfamiliar with microForth.

Re: Another example of factoring and locals

<tkemlq$1t76$1@gioia.aioe.org>

  copy mid

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

  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, 9 Nov 2022 09:53:46 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tkemlq$1t76$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tk512n$1s92$1@gioia.aioe.org>
<dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<tkb4qc$1d6b$1@gioia.aioe.org>
<4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com>
<38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com>
<tkc82v$1frk$1@gioia.aioe.org> <2022Nov8.193406@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62694"; 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, 8 Nov 2022 22:53 UTC

On 9/11/2022 5:34 am, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>> "Don't use local variables. Don't come up with new syntaxs for describing
>> them and new schemes for implementing them. You can make local variables
>> very efficient especially if you have local registers to store them in,
>> but don't. It's bad. It's wrong." - C.M.
>
> Reference needed.

According to Google the source of the quote has been mentioned on c.l.f. on
at least 38 occasions over the years, most recently:

https://groups.google.com/g/comp.lang.forth/c/Wcn1OXpDSzI/m/dEyaxHSKAQAJ

https://groups.google.com/g/comp.lang.forth/c/Wcn1OXpDSzI/m/Q1fWbUCPAQAJ

The quote from Moore himself:

https://youtu.be/pSnNy7IpVMg?t=3192

Re: Another example of factoring and locals

<6eb99ff9-a9c0-46f2-a2cd-c0fcecd11d90n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:4b68:0:b0:3a5:2307:9ed0 with SMTP id g8-20020ac84b68000000b003a523079ed0mr42026471qts.465.1667982322643;
Wed, 09 Nov 2022 00:25:22 -0800 (PST)
X-Received: by 2002:a0d:f446:0:b0:34d:4deb:1155 with SMTP id
d67-20020a0df446000000b0034d4deb1155mr55771338ywf.245.1667982322431; Wed, 09
Nov 2022 00:25:22 -0800 (PST)
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: Wed, 9 Nov 2022 00:25:22 -0800 (PST)
In-Reply-To: <2022Nov8.103948@mips.complang.tuwien.ac.at>
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> <dcbf4bad-9916-480b-9f9c-71ddd262a409n@googlegroups.com>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com> <10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com>
<2022Nov7.232424@mips.complang.tuwien.ac.at> <87h6zal5zu.fsf@nightsong.com> <2022Nov8.103948@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6eb99ff9-a9c0-46f2-a2cd-c0fcecd11d90n@googlegroups.com>
Subject: Re: Another example of factoring and locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 09 Nov 2022 08:25:22 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2402
 by: Hans Bezemer - Wed, 9 Nov 2022 08:25 UTC

On Tuesday, November 8, 2022 at 11:25:56 AM UTC+1, Anton Ertl wrote:
> But anyway, in 1971 Chuck Moore and Ken Thompson (Mr. New Jersey
> approach) were both working on minicomputers of the time, and Moore
> created Forth, and Thompson created Unix. Both Forth and Unix became
> successful, with Forth switching to micros when they became powerful
> enough, and Unix growing with the minis and switching to micros only
> later in the 1980s. This already shows a difference.
There are, however, remarkable similarities between the Forth and Unix design.
First, in Forth everything is a word. In Unix, everything is a file. Second, in Forth,
data is passed transparently and implicitly by the stack. In Unix, data can be
passed transparently and implicitly by pipes.

Hans Bezemer

Re: Another example of factoring and locals

<nnd$4bdac7d0$70f97453@650209835e6e1dc1>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: Another example of factoring and locals
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <4b98fe84-2e7a-4f07-b0dd-2342d72057edn@googlegroups.com> <2022Nov8.193506@mips.complang.tuwien.ac.at> <87o7th2qyc.fsf@nightsong.com>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$4bdac7d0$70f97453@650209835e6e1dc1>
Organization: KPN B.V.
Date: Wed, 09 Nov 2022 11:17:41 +0100
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr1.eu1.usenetexpress.com!94.232.112.245.MISMATCH!feed.abavia.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 37
Injection-Date: Wed, 09 Nov 2022 11:17:41 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2642
 by: none - Wed, 9 Nov 2022 10:17 UTC

In article <87o7th2qyc.fsf@nightsong.com>,
Paul Rubin <no.email@nospam.invalid> wrote:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> if [C.M.'s] old (1971-1978) Forth had been incomprehensible, Forth
>> would not have seen the takeup it has seen. Dean Sanderson would have
>> been unable to design microForth, Seltzer and Ragsdale would have been
>> unable to do fig-Forth, and so on... And I think ... [C.M.]
>> considers the concepts more valuable than the code.
>
>Did Sanderson etc. do their implementations by studying C.M.'s source
>code, or did they simply reimplement its behaviour? I find Forth's
>concepts to be mostly understandable. What I found hard to understand
>was the actual Forth code written by C.M. that I looked at. I also
>found fig-Forth to be hard to understand, if that matters. I'm
>unfamiliar with microForth.

ciforth is actually fig-Forth 5.4.0.
The cvs archive version 1.0 is a copy of a 8086 fig-Forth.
I changed it gradually to 32 bits and replacing BUILD> DOES> with
create/does.
There was no point in time the code was hard to modify or understand.
There was an insight that create-words have actually two data field,
(one data pointer) that can independantly be modified. 1]
There was an insight that literals can be handled by modular,
all but regular words.
These required thinking hard to be implemented
but the fig-Forth code was no hurdle at all.

1] Ting came to the same insight with C++ implementation.

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

<2022Nov9.103332@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Wed, 09 Nov 2022 09:33:32 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 96
Message-ID: <2022Nov9.103332@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com> <tkb4qc$1d6b$1@gioia.aioe.org> <4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com> <38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com> <tkc82v$1frk$1@gioia.aioe.org> <2022Nov8.193406@mips.complang.tuwien.ac.at> <tkemlq$1t76$1@gioia.aioe.org>
Injection-Info: reader01.eternal-september.org; posting-host="72fcd20bee8a7680beeb00f04327c666";
logging-data="228458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ALazt0ZSI9khhiPApwzui"
Cancel-Lock: sha1:bHZY/xMIj5H1mGgG0chCHjjwmJ8=
X-newsreader: xrn 10.11
 by: Anton Ertl - Wed, 9 Nov 2022 09:33 UTC

dxforth <dxforth@gmail.com> writes:
>On 9/11/2022 5:34 am, Anton Ertl wrote:
>> dxforth <dxforth@gmail.com> writes:
>>> "Don't use local variables. Don't come up with new syntaxs for describing
>>> them and new schemes for implementing them. You can make local variables
>>> very efficient especially if you have local registers to store them in,
>>> but don't. It's bad. It's wrong." - C.M.
>>
>> Reference needed.
>
>According to Google the source of the quote has been mentioned on c.l.f. on
>at least 38 occasions over the years, most recently:
>
>https://groups.google.com/g/comp.lang.forth/c/Wcn1OXpDSzI/m/dEyaxHSKAQAJ
>
>https://groups.google.com/g/comp.lang.forth/c/Wcn1OXpDSzI/m/Q1fWbUCPAQAJ

More directly, you mean

http://www.ultratechnology.com/1xforth.htm

>The quote from Moore himself:
>
>https://youtu.be/pSnNy7IpVMg?t=3192

Thanks.

Looking at it again, it's an interesting juxtaposition: First Chuck
Moore talks about the registers A and R in i21 (and I think he has
kept them in his more recent cores), which are useful for MOVE, and he
says that A acts much like a local variable. This leads him to talk
about locals, which he rejects without giving a reason, and then he
goes on to talk about variables, which he considers necessary.
This ties in with some things we have discussed repeatedly over the
years. One reason for having locals was for implementing words that
have so many items in constant use that a pure-stack variant is
cumbersome. An example is MOVE (or, for additional difficulty,
consider a FAXPY-like[1] word on a system with floats on the data stack).
The answer of Elizabeth Rather (IIRC) has been that for
performance-critical words like MOVE, one would write them in assembly
language. For me that's an admission that her kind of Forth is
insufficient for writing these words.

With Forth in hardware, Chuck Moore could not cop out to a more
capable assembler, but he still had a need to write MOVE (probably not
FAXPY), and because traditional Forth was not adequate for that, he
added A and enhanced the capabilities of R. This inspired some people
to think about adding registers to Forth (I dimly remember a talk by
Stephen Pelc), but it seems the idea eventually has not caught on.

I understand why Moore did these additions, and I can see why he did
not want to add locals to his system (especially with both stacks only
6 items deep), but for Forth on general-purpose machines, locals are
superior to these registers: you can have more of them if needed
(e.g., for FAXPY), can name them as appropriate, and don't need to
worry about them being destroyed by a word you call.

There is one property of A (but not R) and (global) variables that
locals and the return stack don't have: you can split a word (as far
as control structures permit) into two parts and data flows through A
and variables automatically between these parts; with locals you have
to arrange explicit passing of these values through the stack. One
can see this as an advantage of A and variables in making factoring
easy, or one can see this as an advantage of locals in forcing to make
the data flow explicit and therefore easier to follow. The latter
advantage is more important for me.

In any case, in classic Forth Moore had provided two stacks instead of
registers despite running on machines that had registers. Why not
expose some of those registers under names like A and R in classic
Forth, and why has A and R not caught on in other Forth systems after
Chuck Moore added them to machine Forth (as the buzz at the time
shows, people were open to this idea)?

The stack provides a nice and convenient interfaces between words,
while register-based interfaces tend to be messy: In any case, you
have to write code for saving and restoring some registers, which is
handled automatically in a stack-based interface; moreover, if each
word has its individual interface for optimum performance, it's hard
to remember, and if you use a common calling convention, you have to
write code for complying with it even though you see how you could do
better by using an individual interface. Better avoid these problems
and stick to the stack.

[1] FAXPY ( ra f-x nstridex f-y nstridey ucount -- ) multiplies ra
with f-x and adds the result to f-y, where f-x and f-y are arrays and
ucount elements are accessed with strides nstridex and nstridey,
respectively. This is the Forth float variant of BLAS's SAXPY,
DAXPY, CAXPY and ZAXPY routines.

- 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

<2022Nov9.114302@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Wed, 09 Nov 2022 10:43:02 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 33
Message-ID: <2022Nov9.114302@mips.complang.tuwien.ac.at>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <874jvd2ita.fsf@nightsong.com> <tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com> <tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com> <6a1d499d-1cc3-4acb-85dd-24838f93d320n@googlegroups.com> <10839720-ce01-412b-ae79-04d881aace7dn@googlegroups.com> <2022Nov7.232424@mips.complang.tuwien.ac.at> <87h6zal5zu.fsf@nightsong.com> <2022Nov8.103948@mips.complang.tuwien.ac.at> <6eb99ff9-a9c0-46f2-a2cd-c0fcecd11d90n@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="72fcd20bee8a7680beeb00f04327c666";
logging-data="228458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190E9HVJvV0erVrwg5Nz7Mg"
Cancel-Lock: sha1:uaKHLMbvwJ3DsOd+4sOi2LFt3d0=
X-newsreader: xrn 10.11
 by: Anton Ertl - Wed, 9 Nov 2022 10:43 UTC

Hans Bezemer <the.beez.speaks@gmail.com> writes:
>There are, however, remarkable similarities between the Forth and Unix design.
>First, in Forth everything is a word. In Unix, everything is a file. Second, in Forth,
>data is passed transparently and implicitly by the stack. In Unix, data can be
>passed transparently and implicitly by pipes.

So yes, both systems centered around a few common abstractions, but
these abstractions were far enough from each other that they show more
difference than commonality.

Comonalities are that they were on small machines, and they were
somewhat comprehensive systems, while these days we tend to think of
Unix as OS, and of Forth as a programming language. Both had no
memory protection (Unix acquired virtual memory only with 3BSD in
1979), both acquired multi-tasking (and multi-user) pretty soon.

But the OS/language difference has been there from the start, only
deepened later; as I wrote in
<2007Dec2.152201@mips.complang.tuwien.ac.at>:

|One difference between Forth and Unix from the start was that Unix had
|files and executables, thus supporting a hard compilation/run-time
|boundary in programming language implementations (and making
|programming languages without that restrictions less favoured), having
|several programming languages, and requiring an additional interpreter
|(the shell) for executing programs.

- 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

<tkg4fj$18f$1@gioia.aioe.org>

  copy mid

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

  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, 9 Nov 2022 22:55:32 +1100
Organization: Aioe.org NNTP Server
Message-ID: <tkg4fj$18f$1@gioia.aioe.org>
References: <2022Oct26.225153@mips.complang.tuwien.ac.at>
<tk5gv2$1thj$1@gioia.aioe.org> <874jvd2ita.fsf@nightsong.com>
<tk722u$1jq1$1@gioia.aioe.org> <87zgd41up3.fsf@nightsong.com>
<tk7sah$1cne$1@gioia.aioe.org> <87r0yf1ilv.fsf@nightsong.com>
<tkb4qc$1d6b$1@gioia.aioe.org>
<4d6d0389-1f71-4934-a489-11f5ee2d7574n@googlegroups.com>
<38b67865-7dde-4c69-9abd-8e101af76039n@googlegroups.com>
<tkc82v$1frk$1@gioia.aioe.org> <2022Nov8.193406@mips.complang.tuwien.ac.at>
<tkemlq$1t76$1@gioia.aioe.org> <2022Nov9.103332@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="1295"; 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 - Wed, 9 Nov 2022 11:55 UTC

On 9/11/2022 8:33 pm, Anton Ertl wrote:
> ...
> One reason for having locals was for implementing words that
> have so many items in constant use that a pure-stack variant is
> cumbersome.

Both are complicated solutions AFAICS. One has lots of stack
operations and the other has lots of variables. They're as bad
as each other. Were folks to see that, they might look for
another solution.

Re: Another example of factoring and locals

<nnd$06f26bb1$30bda3c4@4df1ca99aae48033>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <2022Oct26.225153@mips.complang.tuwien.ac.at> <2022Nov8.193406@mips.complang.tuwien.ac.at> <tkemlq$1t76$1@gioia.aioe.org> <2022Nov9.103332@mips.complang.tuwien.ac.at>
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$06f26bb1$30bda3c4@4df1ca99aae48033>
Organization: KPN B.V.
Date: Wed, 09 Nov 2022 14:59:48 +0100
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 31
Injection-Date: Wed, 09 Nov 2022 14:59:48 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1961
 by: none - Wed, 9 Nov 2022 13:59 UTC

In article <2022Nov9.103332@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
<SNIP>
>
>[1] FAXPY ( ra f-x nstridex f-y nstridey ucount -- ) multiplies ra
>with f-x and adds the result to f-y, where f-x and f-y are arrays and
>ucount elements are accessed with strides nstridex and nstridey,
>respectively. This is the Forth float variant of BLAS's SAXPY,
>DAXPY, CAXPY and ZAXPY routines.

This can be done with nested loops: I and J
Rejecting local variables and then using I and J
(actually similar to adding a special A registers.)
that are a sort of register variables with a special purpose?
I have to admit that feels like cheating.
It makes the case for locals stronger, but local
TO-VALUEs have the same cludgy feeling as I and J.

I feels like you are not going to be able to program, beyond a
certain level of complexity.

>
>- anton

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

<tkgmoh$1eh3$1@gioia.aioe.org>

  copy mid

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

  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: Wed, 9 Nov 2022 17:07:29 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tkgmoh$1eh3$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> <tjva23$120s$1@gioia.aioe.org> <87cza4g1do.fsf@nightsong.com>
Injection-Info: gioia.aioe.org; logging-data="47651"; 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:V7dmLoZZB0qYExUsUXJ/2txRyAc=
X-Notice: Filtered by postfilter v. 0.9.2
 by: antis...@math.uni.wroc.pl - Wed, 9 Nov 2022 17:07 UTC

Paul Rubin <no.email@nospam.invalid> wrote:
> dxforth <dxforth@gmail.com> writes:
> > 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)
>
> In C these days, the extra locals wouldn't expend any resources in most
> cases, since the compiler would optimize them away.
>
> > but I doubt it's Moore's.
>
> This I don't know. A traditional thread Forth interpreter (Moore's
> invention) is probably 10x slower than CODE doing the same thing, but
> Moore only used CODE when he had to. If 9x extra compute cycles is
> fine, why are a few memory cells a big deal?

I think origin of Forth explain this. In his book "PROGRAMMING
A PROBLEM-ORIENTED-LANGUAGE" Moore write about "programs with
input". In more clear language he wanted to have interactive
command processor. For processing user commands even minis
from 1970 and early micros have enough speed that you can lose
some (not too much, but factor of 10 is acceptable). OTOH
some minis were quite small. More writes about 4kB RAM, but
I think that he could put only very stripped down system on
such machine, full system that he outlines probably need
something between 8 and 16 kB RAM (FIG Forth executable is
slightly bigger than 6kB, but needs extra memory for block
buffers and for words defined in Forth).

--
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