Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Life sucks, but death doesn't put out at all...." -- Thomas J. Kopp


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

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

Pages:1234567
Re: Not really locals

<79ecba7b-fe50-43ca-bb90-5d5183adbc95n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:8e49:: with SMTP id w9mr6999831qvb.3.1631469084974;
Sun, 12 Sep 2021 10:51:24 -0700 (PDT)
X-Received: by 2002:a0c:e0c7:: with SMTP id x7mr6980279qvk.55.1631469084670;
Sun, 12 Sep 2021 10:51:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 12 Sep 2021 10:51:24 -0700 (PDT)
In-Reply-To: <2021Sep12.114615@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:2000:2001:e4d:642c:59bb:d29:59b1;
posting-account=ryzhhAoAAAAIqf1uqmG9E4uP1Bagd-k2
NNTP-Posting-Host: 2a01:2000:2001:e4d:642c:59bb:d29:59b1
References: <shapgj$1a32$1@gioia.aioe.org> <87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com> <163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com>
<shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at>
<2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com>
<2021Sep12.114615@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <79ecba7b-fe50-43ca-bb90-5d5183adbc95n@googlegroups.com>
Subject: Re: Not really locals
From: peter.m....@gmail.com (P Falth)
Injection-Date: Sun, 12 Sep 2021 17:51:24 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 87
 by: P Falth - Sun, 12 Sep 2021 17:51 UTC

On Sunday, 12 September 2021 at 12:26:25 UTC+2, Anton Ertl wrote:
> P Falth <peter....@gmail.com> writes:
> >On Saturday, 11 September 2021 at 23:09:03 UTC+2, Anton Ertl wrote:
> >> an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> >> >And of course, lxf produces the same code for 3dup.4 as for all the
> >> >other versions:
> >> >
> >> > 804FC1D 8B4500 mov eax , [ebp]
> >> > 804FC20 8945F4 mov [ebp-Ch] , eax
> >> > 804FC23 8B4504 mov eax , [ebp+4h]
> >> > 804FC26 8945F8 mov [ebp-8h] , eax
> >> > 804FC29 895DFC mov [ebp-4h] , ebx
> >> > 804FC2C 8D6DF4 lea ebp , [ebp-Ch]
> >> > 804FC2F C3 ret near
> >> And the reason is that all four versions consist only of words that
> >> lxf analyses at compile time, so all four versions result in zero
> >> stuff to compile right away, and the same stack state to reconcile
> >> with the calling convention, so the same code is generated (which
> >> consists entirely of the reconciliation with the calling convention).
> >
> >Yes this is correct. But it does not analyse the code. Stack operations
> >just move pointers on a virtual stack, no code is generated.
> In the old days we had plain compilers with peephole optimization
> (e.g., bigForth with peephole optimization on the machine-code level,
> and SwiftForth which AFAIK combines primitives at the Forth level and
> generates code for that), and anything beyond that has been called an
> analytical compiler.
>
> So if your compiler employs arbitrary stack representations by keeping
> track at compile time what stack item resides in what register or what
> memory location, that's an analytical compiler, and keeping track of
> the stack items is analysis.

Good to know I have an analytical compiler!
> Gforth-fast supports few stack representations determined at Gforth
> build time, but only represents them as finite states at compile time
> and cannot keep track of arbitrary stack representations (e.g.,
> already DUP requires at least copying from one register (or memory
> location) to a different register), so I would not classify it as
> analytical.
> >In the example of the rectangle where lxf generated less good code
> >this happened. The code could be written in this way to improve
> >: preprect {: x1 y1 x2 y2 :} x1 y1 x1 y2 x2 y2 x2 y1 x1 y1 ; ok
> >: rect4 preprect moveto lineto lineto lineto lineto ;
> >
> >the preprect will generate 43 bytes of stack shuffling and rect4
> >30 bytes of calls ( 5 calls and one tail jump).
> But when I inline PREPRECT manually, the PREPRECT code becomes quite a
> bit longer, and I see some stores to the return stack. Strange.
> >doing the same for the stack shuffling variant saves even more
> >: rect5 2over 2>r 2>r over r@ 2r> over r@ 2r>
> >moveto lineto lineto lineto lineto ;
> >
> >This will generate 67 bytes, saving one call and one ret.
> >
> >Of course this is a stupid way of actually writing it. But if you want to
> >see what can be achived you will do it.
> It's only stupid is your goal is to write code that is easy to
> understand. If your goal is to produce the shortest code on lxf, it
> is smart:-).
>
> Let's try to make a smart version for VFX:
>
> : rect7 ( x1 y1 x2 y2 -- )
> 3 pick 3 pick over 3 pick 5 pick 2dup 5 pick 5 pick over
> moveto lineto lineto lineto lineto ;
> ( 88 bytes, 25 instructions )

This version is keeping the original 4 parameters on the stack.
A way without returnstack usage could be

: rect8 ( x1 y1 x2 y2 -- )
3 pick -rot swap 2dup 5 pick 5 pick over
moveto lineto lineto lineto lineto ;

Peter

> Hmm; it tends not to keep the items that it has already loaded in
> registers, and therefore has to reload them. lxf does a little better
> at 82 bytes. Admittedly, this is the kind of code that nobody writes,
> so it's understandable if VFX and lxf are not optimized for that.
> - anton
> --
> M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> New standard: http://www.forth200x.org/forth200x.html
> EuroForth 2021: https://euro.theforth.net/2021

Re: Not really locals

<2021Sep12.203312@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Sun, 12 Sep 2021 18:33:12 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 49
Message-ID: <2021Sep12.203312@mips.complang.tuwien.ac.at>
References: <shapgj$1a32$1@gioia.aioe.org> <163128058713.22831.15524277815532345443@media.vsta.org> <35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at> <2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com> <2021Sep12.114615@mips.complang.tuwien.ac.at> <79ecba7b-fe50-43ca-bb90-5d5183adbc95n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="c44f096c1a6c40e22bb5d141b7a34564";
logging-data="9166"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xSTgx+8+XuX+wQkrEtyry"
Cancel-Lock: sha1:LOK/V+wGty6FCXm5LJfNFQXl9/g=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 12 Sep 2021 18:33 UTC

P Falth <peter.m.falth@gmail.com> writes:
>On Sunday, 12 September 2021 at 12:26:25 UTC+2, Anton Ertl wrote:
>> Let's try to make a smart version for VFX:
>>
>> : rect7 ( x1 y1 x2 y2 -- )
>> 3 pick 3 pick over 3 pick 5 pick 2dup 5 pick 5 pick over
>> moveto lineto lineto lineto lineto ;
>> ( 88 bytes, 25 instructions )
>
>This version is keeping the original 4 parameters on the stack.
>A way without returnstack usage could be
>
>: rect8 ( x1 y1 x2 y2 -- )
>3 pick -rot swap 2dup 5 pick 5 pick over
>moveto lineto lineto lineto lineto ;

Thanks for debugging it. This takes 73bytes on VFX, 67 on lxf.

It should be doable with 4 loads, 7 stores, one lea, 4 calls and one
jmp; 4*3+7*3+1*3+4*5+1*5=61 bytes.

lea ebp,[ebp-18h]
mov eax,[ebp+18h] #x2 #a
mov edx,[ebp+14h] #y2
mov [ebp],ebx #x1 #b
mov [ebp+18h],ebx #c
mov ebx,[ebp+1ch] #y1 #d
mov [ebp+10h],eax
mov [ebp+0ch],edx
mov [ebp+08h],eax
mov [ebp+04h],ebx
call MOVETO
call LINETO
call LINETO
call LINETO
jmp LINETO

You cannot just do the loads upfront, you have to do load #d after
stores #b and #c. You also have to do load #a before the store #c.

If you do all the loads upfront, you eventually need a
register-to-register move to get y1 into ebx.

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

Re: Not really locals

<2021Sep12.214858@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Sun, 12 Sep 2021 19:48:58 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 30
Message-ID: <2021Sep12.214858@mips.complang.tuwien.ac.at>
References: <shapgj$1a32$1@gioia.aioe.org> <35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at> <2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com> <2021Sep12.114615@mips.complang.tuwien.ac.at> <79ecba7b-fe50-43ca-bb90-5d5183adbc95n@googlegroups.com> <2021Sep12.203312@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="c44f096c1a6c40e22bb5d141b7a34564";
logging-data="9166"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jZ8HlzUh2k99mhFdX0ScQ"
Cancel-Lock: sha1:gjF1CDvt8hU9zUpswAIJIseXqNE=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 12 Sep 2021 19:48 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>It should be doable with 4 loads, 7 stores, one lea, 4 calls and one
>jmp; 4*3+7*3+1*3+4*5+1*5=61 bytes.
>
>lea ebp,[ebp-18h]
>mov eax,[ebp+18h] #x2 #a
>mov edx,[ebp+14h] #y2
>mov [ebp],ebx #x1 #b
>mov [ebp+18h],ebx #c
>mov ebx,[ebp+1ch] #y1 #d
>mov [ebp+10h],eax
>mov [ebp+0ch],edx
>mov [ebp+08h],eax
>mov [ebp+04h],ebx
>call MOVETO
>call LINETO
>call LINETO
>call LINETO
>jmp LINETO

So actually you need only 3 loads (x1 is already in a register at the
start), and only 6 stores (you don't need to store the TOS into
memory), resulting in 55 bytes for the whole thing.

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

Re: Not really locals

<87fsu97bgc.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Sun, 12 Sep 2021 14:04:03 -0700
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <87fsu97bgc.fsf@nightsong.com>
References: <shapgj$1a32$1@gioia.aioe.org>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at>
<871r5u936m.fsf@nightsong.com>
<2021Sep12.105636@mips.complang.tuwien.ac.at>
<shknb5$15fl$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ba54d55f56f7c6ebe10fbd14de294cd6";
logging-data="13422"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183JZ85F5x7UzpR6LrWfkcC"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:Syu2NtT8/wff4myFwmW+wReGhbg=
sha1:UfPyQCpqNT5K07ZY5fFPQfyZ8Rg=
 by: Paul Rubin - Sun, 12 Sep 2021 21:04 UTC

dxforth <dxforth@gmail.com> writes:
> If good coding produces good results on any system then surely it is
> coding worth learning.

If by good results you mean the fastest possible execution, that has
always required painful hacks and sometimes very carefully written
assembly code, usually tuned to the specific processor architecture.
Doing that is sometimes necessary and sometimes fun, but it is a niche
skill that most programmers today don't have. "Good coding" at least to
me means writing clear and maintainable code whose performance is
reasonable for that development approach, and which suffices for the
application.

> To my knowledge there is no VFX/LXF/GForth for CP/M systems. OTOH
> there does appear to be many RC2014 Z80 systems and a surprising
> degree of interest in forth. Their users weren't lured by locals.
> They came for the full-on Forth experience.

What is RC2014? Today's equivalent of CP/M systems is microcontroller
systems (say the Raspberry Pi RP2040, and the equivalent of Forth is
MicroPython. A MicroPython program is likely to be 10x slower than the
equivalent Forth program on the same hardware, but since the hardware is
100x faster than a Z80, the MicroPython RP2040 user can easily solve the
same problems as the Z80 Forth user.

Forth after all was historically a straightforwardly implemented,
interpreted language, that was faster than other interpreted languages
like BASIC. If your program had a speed bottleneck you'd handle that by
writing CODE words. Fancy Forth compilers whose output competed with
handwritten assembly code came much later.

The CPU I'm currently interested in (ATTiny) is more like a Z80 (though
still much faster), and it is treated as somewhat obsolescent in the MCU
world.

Re: Not really locals

<87bl4x7axr.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Sun, 12 Sep 2021 14:15:12 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <87bl4x7axr.fsf@nightsong.com>
References: <shapgj$1a32$1@gioia.aioe.org>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com>
<2021Sep11.083507@mips.complang.tuwien.ac.at>
<3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com>
<2021Sep12.123956@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ba54d55f56f7c6ebe10fbd14de294cd6";
logging-data="13422"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5kLF+DtRQT4gc4+NyH8Nk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:rzFeU6Q1DXbXSmu4wyPbGAOpOA0=
sha1:suk8K+dw/ZxSfhP8hP2NJwEMKFs=
 by: Paul Rubin - Sun, 12 Sep 2021 21:15 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> Tough luck. If you cannot explain the concrete benefits of your
> philosophy on a concrete example, the rest of the world cannot
> distinguish it from mumbo-jumbo.

I would say it is often valuable to read an entire book and come away
from it with a philosophical lesson you can use later, that could not be
crystallized into a concrete example. The trouble is that multiple
readers will have different interpretations and won't always come away
with the same lesson. There is a whole industry of literary criticism
which is about comparing different interpretations of the same book.
I'm sure that literary critics have written lots of entire books that
try to explain the philosophical lessons of Shakespeare's "Hamlet".

Here, Hans Bezemer has advised me to read Thinking Forth in order to
receive a philosophical lesson about the evils of locals. I'm open to
having such an experience, but I have read the book before and looked at
it again last night, and that particular point didn't come across to me
either time. Maybe we need some literary critics to analyze Thinking
Forth and explain what its lessons are. A good starting point might be
identifying a page number where Thinking Forth says anything at all
about locals.

Re: static type checking

<8735q97aeg.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: static type checking
Date: Sun, 12 Sep 2021 14:26:47 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <8735q97aeg.fsf@nightsong.com>
References: <shapgj$1a32$1@gioia.aioe.org>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com>
<2021Sep11.083507@mips.complang.tuwien.ac.at>
<3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com>
<87o88y7duy.fsf@nightsong.com>
<2021Sep12.131651@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ba54d55f56f7c6ebe10fbd14de294cd6";
logging-data="13422"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19aCwG+1cLiBTv8vSRidZAT"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:3cMJ602b5TkW5wyTKPitYKysP+4=
sha1:R+3ZTqbJqUmjitr26sQsnx5145c=
 by: Paul Rubin - Sun, 12 Sep 2021 21:26 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> There are package repositories like CPAN and PyPI for dynamic
> languages, but efforts like this for static languages have not been
> similarly successful; e.g., in the case of Java, CJAN ceased
> development in 2004 and Apache JJAR is essentially abandoned.

I think that says more about Java culture than static types. Take a
look at hackage.haskell.org as a package repo for a much less widely
used language than Java. There is a ton of stuff there. The types
help, they really do, at least most of the time. It otherwise becomes
too cumbersome to remember what is what.

Rust also has a package library that has lots of stuff, though I haven't
used it or tried Rust yet.

Re: Not really locals

<shmh7i$u00$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 13:40:35 +1000
Organization: Aioe.org NNTP Server
Message-ID: <shmh7i$u00$1@gioia.aioe.org>
References: <shapgj$1a32$1@gioia.aioe.org>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at> <871r5u936m.fsf@nightsong.com>
<2021Sep12.105636@mips.complang.tuwien.ac.at> <shknb5$15fl$1@gioia.aioe.org>
<87fsu97bgc.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="30720"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 13 Sep 2021 03:40 UTC

On 13/09/2021 07:04, Paul Rubin wrote:
> dxforth <dxforth@gmail.com> writes:
>> If good coding produces good results on any system then surely it is
>> coding worth learning.
>
> If by good results you mean the fastest possible execution, that has
> always required painful hacks and sometimes very carefully written
> assembly code, usually tuned to the specific processor architecture.
> Doing that is sometimes necessary and sometimes fun, but it is a niche
> skill that most programmers today don't have. "Good coding" at least to
> me means writing clear and maintainable code whose performance is
> reasonable for that development approach, and which suffices for the
> application.

Clear and maintainable to whom - someone who is familiar with C et al.
Moore saw no distinction between learning Forth and learning other
languages - they all require effort. As to the barriers of learning
the former, he said:

"It is very hard to interest an experienced programmer in Forth. That’s
because he has invested in learning the tools for his language/operating
system and has built a library appropriate for his applications. Telling
him that Forth would be smaller, faster, and easier is not persuasive
compared to having to recode everything. A novice programmer, or an
engineer needing to write code, doesn’t face that obstacle and is much
more receptive - as might be the experienced programmer starting a new
project with new constraints"

>
>> To my knowledge there is no VFX/LXF/GForth for CP/M systems. OTOH
>> there does appear to be many RC2014 Z80 systems and a surprising
>> degree of interest in forth. Their users weren't lured by locals.
>> They came for the full-on Forth experience.
>
> What is RC2014? Today's equivalent of CP/M systems is microcontroller
> systems (say the Raspberry Pi RP2040, and the equivalent of Forth is
> MicroPython. A MicroPython program is likely to be 10x slower than the
> equivalent Forth program on the same hardware, but since the hardware is
> 100x faster than a Z80, the MicroPython RP2040 user can easily solve the
> same problems as the Z80 Forth user.

There it is in your own words. You have no reason to learn Forth.

Re: Not really locals

<87tuip5eax.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Sun, 12 Sep 2021 20:45:26 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <87tuip5eax.fsf@nightsong.com>
References: <shapgj$1a32$1@gioia.aioe.org>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at>
<871r5u936m.fsf@nightsong.com>
<2021Sep12.105636@mips.complang.tuwien.ac.at>
<shknb5$15fl$1@gioia.aioe.org> <87fsu97bgc.fsf@nightsong.com>
<shmh7i$u00$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="79a1eb81eb865486a95025475e7d0fc6";
logging-data="16046"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18arOw4yogJjWoCNPtzslSU"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:YrDnW3TZsEx4WKM9EuCEC6pzqn8=
sha1:BaTV0wUkJcCQ3SUW+oXwC4HRA+0=
 by: Paul Rubin - Mon, 13 Sep 2021 03:45 UTC

dxforth <dxforth@gmail.com> writes:
> Moore saw no distinction between learning Forth and learning other
> languages - they all require effort. As to the barriers of learning
> the former, he said:

I don't find that. Some are harder than others. Haskell is relatively
hard. Forth is simple, but using it effectively without locals is a big
pain. It seems to take a lot of practice, like playing chess, to train
yourself in the stack juggling methods. If you train yourself at chess
enough, you can get to win chess games, which is nice. What do you get
by training at stack juggling, when you can use locals?

>> the MicroPython RP2040 user can easily solve the same problems as the
>> Z80 Forth user.
> There it is in your own words. You have no reason to learn Forth.

If my application was on an RP2040 I'd certainly do this extension part
in MicroPython or something similar. The RP2040 is a 32-bit cpu with
256k of ram on the chip. I'm instead on an 8-bit AVR with 2k of ram, so
that means Forth.

Re: Not really locals

<shmk1k$1o1q$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 14:28:38 +1000
Organization: Aioe.org NNTP Server
Message-ID: <shmk1k$1o1q$1@gioia.aioe.org>
References: <shapgj$1a32$1@gioia.aioe.org>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at> <871r5u936m.fsf@nightsong.com>
<2021Sep12.105636@mips.complang.tuwien.ac.at> <shknb5$15fl$1@gioia.aioe.org>
<87fsu97bgc.fsf@nightsong.com> <shmh7i$u00$1@gioia.aioe.org>
<87tuip5eax.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="57402"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 13 Sep 2021 04:28 UTC

On 13/09/2021 13:45, Paul Rubin wrote:
> dxforth <dxforth@gmail.com> writes:
>> Moore saw no distinction between learning Forth and learning other
>> languages - they all require effort. As to the barriers of learning
>> the former, he said:
>
> I don't find that. Some are harder than others. Haskell is relatively
> hard. Forth is simple, but using it effectively without locals is a big
> pain. It seems to take a lot of practice, like playing chess, to train
> yourself in the stack juggling methods. If you train yourself at chess
> enough, you can get to win chess games, which is nice. What do you get
> by training at stack juggling, when you can use locals?
>
>>> the MicroPython RP2040 user can easily solve the same problems as the
>>> Z80 Forth user.
>> There it is in your own words. You have no reason to learn Forth.
>
> If my application was on an RP2040 I'd certainly do this extension part
> in MicroPython or something similar. The RP2040 is a 32-bit cpu with
> 256k of ram on the chip. I'm instead on an 8-bit AVR with 2k of ram, so
> that means Forth.
>

Room enough it appears for big dreams about using locals. Good luck.

Re: Not really locals

<87pmtd58vd.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Sun, 12 Sep 2021 22:42:46 -0700
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <87pmtd58vd.fsf@nightsong.com>
References: <shapgj$1a32$1@gioia.aioe.org> <87o892rgny.fsf@nightsong.com>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at>
<2021Sep11.222320@mips.complang.tuwien.ac.at>
<9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com>
<87k0jm6zou.fsf@nightsong.com>
<d7c85a4e-65fd-4460-bfbd-af81d3d6e55bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="79a1eb81eb865486a95025475e7d0fc6";
logging-data="14824"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19StDoicdHpS5f/X/D8T0EK"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:Gxn5kzqfq1wJDdybFmv4bbd0I28=
sha1:T+SLPSWRriWHf1edhmy9mmM6DAE=
 by: Paul Rubin - Mon, 13 Sep 2021 05:42 UTC

P Falth <peter.m.falth@gmail.com> writes:
> I have to words that control the virtual stacks. v-init ( n --) and
> v-exit ( n-- )

Thanks for explaining. Do you ever now use n > 1? Or does inlining
eliminate enough of the places where it could do any good?

> When there is a control flow break ( if begin then etc) the stack must
> be set to a know state with 1 v-exit.

For something like "xxx IF foo ELSE bar THEN" is there an obstacle to
copying the v-stack state into both branches, so that you can try
inlining foo and bar and see how well those fit the current v-stack?

In general, does the compiler try different combinations of inlining to
see what works best?

I guess the virtual stacks connect the virtual stack slots to real
locations, which can be slots in the normal D and R stacks (maybe not
with the same slot numbers), plus machine registers. Do you also spill
to memory or maybe some other place, if you run out of registers? Do
you need a register allocator of the sort that fancy compilers have?

> [source inlining] has a problem of late binding and possibility of
> redifinitions and wordlist order. In my 64 bit lxf64 I compile first
> to tokenthreaded code to solve this problem

I think I understand: the token threaded code reflects the source code,
but it gets updated as source words are redefined. And you make a token
for each dictionary word. Let me know if I got that wrong.

> The compiler is about 1500 lines of code 50k bytes so it is not big.

That's impressively small for a compiler, but quite big compared to
anything I've done in Forth so far. I only use a very primitive level
of Forth for the most part (no OOP or anything like that).

Dare I ask if it uses locals? ;-)

> I think the biggest problem is that you need a good integration with
> an assembler to generate the final code... in lxf64 I generate intel
> asm source and send it to an external assembler dll that returns the
> compiled blob.

I guess that must be because of the enormously complex x64 instruction
set. On simpler processors I'm hoping to use a traditional FIG-style
assembler written in Forth.

> Other than that duped stack items require some consideration.

It seems to me also, some forward thinking is required to have stack
items early in a word land in their desired final destinations so they
don't have to be moved. Was that an issue?

> I think Forth is an ideal language to write this in as you can start
> with a few words using the code generator and then test and continue
> with others

Nice! I'll keep that in mind.

Re: Not really locals

<a2bfb2e4-4daf-4cc4-8ac1-b72f80629402n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:5569:: with SMTP id w9mr4776322qvy.52.1631512208628;
Sun, 12 Sep 2021 22:50:08 -0700 (PDT)
X-Received: by 2002:a05:620a:1598:: with SMTP id d24mr8448152qkk.484.1631512208484;
Sun, 12 Sep 2021 22:50:08 -0700 (PDT)
Path: i2pn2.org!rocksolid2!news.neodome.net!3.eu.feeder.erje.net!feeder.erje.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: Sun, 12 Sep 2021 22:50:08 -0700 (PDT)
In-Reply-To: <2021Sep12.203312@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:60c1:7b64:6129:b427;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:60c1:7b64:6129:b427
References: <shapgj$1a32$1@gioia.aioe.org> <163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com>
<shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at>
<2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com>
<2021Sep12.114615@mips.complang.tuwien.ac.at> <79ecba7b-fe50-43ca-bb90-5d5183adbc95n@googlegroups.com>
<2021Sep12.203312@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a2bfb2e4-4daf-4cc4-8ac1-b72f80629402n@googlegroups.com>
Subject: Re: Not really locals
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Mon, 13 Sep 2021 05:50:08 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Marcel Hendrix - Mon, 13 Sep 2021 05:50 UTC

On Sunday, September 12, 2021 at 9:17:10 PM UTC+2, Anton Ertl wrote:
> P Falth <peter....@gmail.com> writes:
> >On Sunday, 12 September 2021 at 12:26:25 UTC+2, Anton Ertl wrote:
> >> Let's try to make a smart version for VFX:
> >>
> >> : rect7 ( x1 y1 x2 y2 -- )
> >> 3 pick 3 pick over 3 pick 5 pick 2dup 5 pick 5 pick over
> >> moveto lineto lineto lineto lineto ;
> >> ( 88 bytes, 25 instructions )
> >
> >This version is keeping the original 4 parameters on the stack.
> >A way without returnstack usage could be
> >
> >: rect8 ( x1 y1 x2 y2 -- )
> >3 pick -rot swap 2dup 5 pick 5 pick over
> >moveto lineto lineto lineto lineto ;
> Thanks for debugging it. This takes 73bytes on VFX, 67 on lxf.
>
> It should be doable with 4 loads, 7 stores, one lea, 4 calls and one
> jmp; 4*3+7*3+1*3+4*5+1*5=61 bytes.
>
> lea ebp,[ebp-18h]
> mov eax,[ebp+18h] #x2 #a
> mov edx,[ebp+14h] #y2
> mov [ebp],ebx #x1 #b
> mov [ebp+18h],ebx #c
> mov ebx,[ebp+1ch] #y1 #d
> mov [ebp+10h],eax
> mov [ebp+0ch],edx
> mov [ebp+08h],eax
> mov [ebp+04h],ebx
> call MOVETO
> call LINETO
> call LINETO
> call LINETO
> jmp LINETO

RECT8 (without the four calls and the jump) can be done in 25 bytes:

: rect8 3 PICK -ROT SWAP 2DUP 5 PICK 5 PICK OVER ; ok
FORTH> ' rect8 idis
$0133CC00 : rect8
$0133CC0A mov rbx, [rsp #24 +] qword
$0133CC0F pop rdi
$0133CC10 pop rax
$0133CC11 push rbx
$0133CC12 push rdi
$0133CC13 push rax
$0133CC14 push rdi
$0133CC15 push rax
$0133CC16 mov rbx, [rsp #40 +] qword
$0133CC1B mov rcx, rbx
$0133CC1E mov rbx, [rsp #32 +] qword
$0133CC23 push rcx
$0133CC24 push rbx
$0133CC25 push rcx
$0133CC26 ;
$0133CC30 cmp rbx, rbx
FORTH> $0133CC26 $0133CC0A - . 28 ok

-marcel

Re: Not really locals

<87lf4157xc.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Sun, 12 Sep 2021 23:03:11 -0700
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <87lf4157xc.fsf@nightsong.com>
References: <shapgj$1a32$1@gioia.aioe.org> <87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at>
<2021Sep11.222320@mips.complang.tuwien.ac.at>
<9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com>
<87k0jm6zou.fsf@nightsong.com>
<2021Sep12.132752@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="79a1eb81eb865486a95025475e7d0fc6";
logging-data="20710"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iWJwG2HORMU0LTk4amq6+"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:/3sFlz23xGsI+Rioy3aNmCZDnz4=
sha1:wIxqeNdWi0GgmiDAPbFiz2+GoF0=
 by: Paul Rubin - Mon, 13 Sep 2021 06:03 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> There are more optimal ways, and I can look them up if you want, but
> they are not simpler.

At the moment I think I need "simple", but thanks ;-).

I found an interesting article by Doneil Hoekman about a "Universal
Stack Word", in Forth Dimensions v07n5 (1986), p. 25,
http://forth.org/fd/FD-V07N5.pdf . He wrote a parsing word STACK that
reads a before-and-after stack picture and rearranges the stack
according to the picture. He gives examples of how to redefine some
standard Forth words:

: DROP STACK A| ;
: DUP STACK A|AA ;
: SWAP STACK AB|BA ;
: ROT STACK ABC|BCA ;
: 2SWAP STACK ABCD|CDAB ;

I didn't examine the "motion planning" for this, but I can see that it
is sort of related.

Re: Not really locals

<2021Sep13.080614@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 06:06:14 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 45
Message-ID: <2021Sep13.080614@mips.complang.tuwien.ac.at>
References: <shapgj$1a32$1@gioia.aioe.org> <163128058713.22831.15524277815532345443@media.vsta.org> <35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at> <2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com> <87k0jm6zou.fsf@nightsong.com> <d7c85a4e-65fd-4460-bfbd-af81d3d6e55bn@googlegroups.com> <87pmtd58vd.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="adc1cc9999d4f6f902b7838f9a4a2636";
logging-data="17086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oFma99jGaanHM/CKV1JWY"
Cancel-Lock: sha1:yOqRcYSeDWj7NnFvnoNQp3Gs8O8=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 13 Sep 2021 06:06 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>P Falth <peter.m.falth@gmail.com> writes:
>> [source inlining] has a problem of late binding and possibility of
>> redifinitions and wordlist order. In my 64 bit lxf64 I compile first
>> to tokenthreaded code to solve this problem
>
>I think I understand: the token threaded code reflects the source code,
>but it gets updated as source words are redefined. And you make a token
>for each dictionary word. Let me know if I got that wrong.

Consider:

: foo ... ;
: bar ... foo ... ;
: foo ... ;
: baz ... bar ... ;

The FOO in BAR refers to the first definition of FOO. When compiling
BAZ, which inlines BAR, source inlining would compile (or inline) a
call to the second definition of FOO. You can also have examples
where different search orders are involved. The way to fix this is to
resolve the names when they are originally compiled, e.g., by
compiling the word into token-threaded code which is then used for
inlining. So the point is *not* to update this code for BAR when
another FOO is defined.

>I guess that must be because of the enormously complex x64 instruction
>set.

Here are numbers from Gforth:

[~/gforth:124764] wc -l arch/amd64/{asm.fs,disasm.fs}
732 arch/amd64/asm.fs
610 arch/amd64/disasm.fs
1342 total

This includes SSE2; not sure how much more of the SIMD stuff is
supported.

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

Re: Not really locals

<2021Sep13.082416@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 06:24:16 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 78
Message-ID: <2021Sep13.082416@mips.complang.tuwien.ac.at>
References: <shapgj$1a32$1@gioia.aioe.org> <87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at> <2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com> <2021Sep12.114615@mips.complang.tuwien.ac.at> <79ecba7b-fe50-43ca-bb90-5d5183adbc95n@googlegroups.com> <2021Sep12.203312@mips.complang.tuwien.ac.at> <a2bfb2e4-4daf-4cc4-8ac1-b72f80629402n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="adc1cc9999d4f6f902b7838f9a4a2636";
logging-data="17086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Xo46enbh4AwQrjw/5DqVB"
Cancel-Lock: sha1:UhtyvFB84fbxU1ivd4uH1dhLWeo=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 13 Sep 2021 06:24 UTC

Marcel Hendrix <mhx@iae.nl> writes:
>On Sunday, September 12, 2021 at 9:17:10 PM UTC+2, Anton Ertl wrote:
>> P Falth <peter....@gmail.com> writes:
>> >On Sunday, 12 September 2021 at 12:26:25 UTC+2, Anton Ertl wrote:
>> >> Let's try to make a smart version for VFX:
>> >>
>> >> : rect7 ( x1 y1 x2 y2 -- )
>> >> 3 pick 3 pick over 3 pick 5 pick 2dup 5 pick 5 pick over
>> >> moveto lineto lineto lineto lineto ;
>> >> ( 88 bytes, 25 instructions )
>> >
>> >This version is keeping the original 4 parameters on the stack.
>> >A way without returnstack usage could be
>> >
>> >: rect8 ( x1 y1 x2 y2 -- )
>> >3 pick -rot swap 2dup 5 pick 5 pick over
>> >moveto lineto lineto lineto lineto ;
>> Thanks for debugging it. This takes 73bytes on VFX, 67 on lxf.
>>
>> It should be doable with 4 loads, 7 stores, one lea, 4 calls and one
>> jmp; 4*3+7*3+1*3+4*5+1*5=61 bytes.
>>
>> lea ebp,[ebp-18h]
>> mov eax,[ebp+18h] #x2 #a
>> mov edx,[ebp+14h] #y2
>> mov [ebp],ebx #x1 #b
>> mov [ebp+18h],ebx #c
>> mov ebx,[ebp+1ch] #y1 #d
>> mov [ebp+10h],eax
>> mov [ebp+0ch],edx
>> mov [ebp+08h],eax
>> mov [ebp+04h],ebx
>> call MOVETO
>> call LINETO
>> call LINETO
>> call LINETO
>> jmp LINETO
>
>RECT8 (without the four calls and the jump) can be done in 25 bytes:
>
>: rect8 3 PICK -ROT SWAP 2DUP 5 PICK 5 PICK OVER ; ok
>FORTH> ' rect8 idis
>$0133CC00 : rect8
>$0133CC0A mov rbx, [rsp #24 +] qword
>$0133CC0F pop rdi
>$0133CC10 pop rax
>$0133CC11 push rbx
>$0133CC12 push rdi
>$0133CC13 push rax
>$0133CC14 push rdi
>$0133CC15 push rax
>$0133CC16 mov rbx, [rsp #40 +] qword
>$0133CC1B mov rcx, rbx
>$0133CC1E mov rbx, [rsp #32 +] qword
>$0133CC23 push rcx
>$0133CC24 push rbx
>$0133CC25 push rcx
>$0133CC26 ;
>$0133CC30 cmp rbx, rbx
>FORTH> $0133CC26 $0133CC0A - . 28 ok

Or do three pops, 9 pushes, and one register-register move (15 bytes).
However, code size is not everything. Most CPUs can only do one store
per cycle, which means that the stores in my version above take 6
cycles, the stores in the iForth-generated version take 8 cycles, and
the 9-push version takes 9 cycles. Out-of-order execution can push
outstanding store to later, which can help in some cases. But in this
case, I don't think that this is such a case, because I expect that
the MOVETO will load some of the store results right away. In the
version I posted above it would probably be better to order the stores
such that the items closer to the top are stored early.

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

Re: Not really locals

<shmtc4$113i$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 17:07:48 +1000
Organization: Aioe.org NNTP Server
Message-ID: <shmtc4$113i$1@gioia.aioe.org>
References: <shapgj$1a32$1@gioia.aioe.org> <87o892rgny.fsf@nightsong.com>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <2021Sep11.083507@mips.complang.tuwien.ac.at>
<3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com>
<87o88y7duy.fsf@nightsong.com>
<9df6a9f7-06e2-4454-adce-732a46e7a845n@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="33906"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 13 Sep 2021 07:07 UTC

On 13/09/2021 03:23, S Jack wrote:
>
> <saga> Lets make Forth great again!

Forth lost?

> In industry a manager stands in quicksand with alligators biting at
> his butt, his arms tightly bound by a boa going for his neck,
> and his head in a cloud of mosquitoes and hornets. Along the dry bank
> comes whistling and skipping a little programmer. He sees the
> manager and shouts "Hey Boss, I got just the thing to fix all your
> problems. It's called FORTH!".

That would be the Forth industrial complex talking. Moore has always
been more circumspect as to who might benefit from Forth. Let's just
say his opinion of the average programmer isn't great. Luckily forthers
are all above average.

Re: Not really locals

<4f087736-7f20-4390-9c2a-1f3fd41c0ab7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:4c9c:: with SMTP id j28mr7979376qtv.224.1631517708203;
Mon, 13 Sep 2021 00:21:48 -0700 (PDT)
X-Received: by 2002:a05:622a:3d4:: with SMTP id k20mr8074270qtx.417.1631517707895;
Mon, 13 Sep 2021 00:21:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 13 Sep 2021 00:21:47 -0700 (PDT)
In-Reply-To: <87pmtd58vd.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:2000:2001:e4d:e050:f633:2cc1:186f;
posting-account=ryzhhAoAAAAIqf1uqmG9E4uP1Bagd-k2
NNTP-Posting-Host: 2a01:2000:2001:e4d:e050:f633:2cc1:186f
References: <shapgj$1a32$1@gioia.aioe.org> <87o892rgny.fsf@nightsong.com>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com> <856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com> <1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org> <35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at> <2021Sep11.222320@mips.complang.tuwien.ac.at>
<9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com> <87k0jm6zou.fsf@nightsong.com>
<d7c85a4e-65fd-4460-bfbd-af81d3d6e55bn@googlegroups.com> <87pmtd58vd.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4f087736-7f20-4390-9c2a-1f3fd41c0ab7n@googlegroups.com>
Subject: Re: Not really locals
From: peter.m....@gmail.com (P Falth)
Injection-Date: Mon, 13 Sep 2021 07:21:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 94
 by: P Falth - Mon, 13 Sep 2021 07:21 UTC

On Monday, 13 September 2021 at 07:43:02 UTC+2, Paul Rubin wrote:
> P Falth <peter....@gmail.com> writes:
> > I have to words that control the virtual stacks. v-init ( n --) and
> > v-exit ( n-- )
> Thanks for explaining. Do you ever now use n > 1? Or does inlining
> eliminate enough of the places where it could do any good?

Yes in some places n>1 is used. One example is in compiling a constant
There it is used as it creates smaller code.

I should also explain that there is not "one" code generator. Instead each
word is its own code generator. There are about 400 words that have special
code generators. User defined words generate only a call to its compiled
code. There is a possibility to do user defined macros that source inline.

> > When there is a control flow break ( if begin then etc) the stack must
> > be set to a know state with 1 v-exit.
> For something like "xxx IF foo ELSE bar THEN" is there an obstacle to
> copying the v-stack state into both branches, so that you can try
> inlining foo and bar and see how well those fit the current v-stack?

The code generation does not stop after a v-exit it continues but from the new
known state. For sure foo and bar will be able to generate code.
I had from the beginning the idea to save and restore virtual stacks at
branches but it got to complicated.

> In general, does the compiler try different combinations of inlining to
> see what works best?

No nothing like that. That is up to the programmer to discover what
source generates the best code. SEE is a very useful tool for that
> I guess the virtual stacks connect the virtual stack slots to real
> locations, which can be slots in the normal D and R stacks (maybe not
> with the same slot numbers), plus machine registers. Do you also spill
> to memory or maybe some other place, if you run out of registers? Do
> you need a register allocator of the sort that fancy compilers have?

Yes and there are also immediate values (known at compile time)
that are stored directly in the virtual stacks. If for ex. an add operation
sees that the 2 top stack items are immediate values they are added
and the result stored in the virtual stack.

If I run out of registers they are stored to memory. The register allocator
is not sophisticated. It just picks the first register in a list of free registers.
When not needed anymore they are returned to the free list.
> > [source inlining] has a problem of late binding and possibility of
> > redifinitions and wordlist order. In my 64 bit lxf64 I compile first
> > to tokenthreaded code to solve this problem
> I think I understand: the token threaded code reflects the source code,
> but it gets updated as source words are redefined. And you make a token
> for each dictionary word. Let me know if I got that wrong.

Yes you got it wrong. The tokens are like opcodes in a CPU. In the VM
of lxf64 there are currently 155 opcodes. From the forth point of view
it is running natively on a CPU ( the VM). There is a call opcode to
just like on a normal cpu. In fact lxf64 runs perfectly well on the VM.

> > The compiler is about 1500 lines of code 50k bytes so it is not big.
> That's impressively small for a compiler, but quite big compared to
> anything I've done in Forth so far. I only use a very primitive level
> of Forth for the most part (no OOP or anything like that).
>
> Dare I ask if it uses locals? ;-)

For sure. It does not. I started using FORTH before locals was introduced
and have never seen a need to use them.

As a side-note. I also stopped using VALUES when TO got overloaded.
I have never missed them.

> > I think the biggest problem is that you need a good integration with
> > an assembler to generate the final code... in lxf64 I generate intel
> > asm source and send it to an external assembler dll that returns the
> > compiled blob.
> I guess that must be because of the enormously complex x64 instruction
> set. On simpler processors I'm hoping to use a traditional FIG-style
> assembler written in Forth.

Yes that is exactly what i use in lxf. For lxf64 I tried loading the assembler
from gforth. It doubled the size of my forth imagefile!. lxf64 compiles
a complete forth2012 compliant system in an image file of 46k bytes.
But now instead i have 2.5MB dll for assembler and 1.5 MB for disassembler

Peter

> > Other than that duped stack items require some consideration.
> It seems to me also, some forward thinking is required to have stack
> items early in a word land in their desired final destinations so they
> don't have to be moved. Was that an issue?
> > I think Forth is an ideal language to write this in as you can start
> > with a few words using the code generator and then test and continue
> > with others
> Nice! I'll keep that in mind.

Re: Not really locals

<36c1eba4-3433-4e29-b5b7-347832787406n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:4744:: with SMTP id k4mr7988824qtp.247.1631518458708;
Mon, 13 Sep 2021 00:34:18 -0700 (PDT)
X-Received: by 2002:a05:620a:2a14:: with SMTP id o20mr8720212qkp.286.1631518458570;
Mon, 13 Sep 2021 00:34:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 13 Sep 2021 00:34:18 -0700 (PDT)
In-Reply-To: <87bl4x7axr.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <shapgj$1a32$1@gioia.aioe.org> <6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com> <87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com> <163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com>
<2021Sep11.083507@mips.complang.tuwien.ac.at> <3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com>
<2021Sep12.123956@mips.complang.tuwien.ac.at> <87bl4x7axr.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <36c1eba4-3433-4e29-b5b7-347832787406n@googlegroups.com>
Subject: Re: Not really locals
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Mon, 13 Sep 2021 07:34:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 75
 by: Hans Bezemer - Mon, 13 Sep 2021 07:34 UTC

On Sunday, September 12, 2021 at 11:15:13 PM UTC+2, Paul Rubin wrote:
> Here, Hans Bezemer has advised me to read Thinking Forth in order to
> receive a philosophical lesson about the evils of locals. I'm open to
> having such an experience, but I have read the book before and looked at
> it again last night, and that particular point didn't come across to me
> either time. Maybe we need some literary critics to analyze Thinking
> Forth and explain what its lessons are. A good starting point might be
> identifying a page number where Thinking Forth says anything at all
> about locals.
Try chapter 7, "The Stylish Stack"?

There is a reason you won't find anything on locals, because it violates its basic philosophy ("stamp out the variables").

I've taken the liberty to pick some quotes from it. Of course, this opens up attacks like "cherry picking", but if you think so, go cherry picking yourself.

"Forth is a language,an operating system, a set of tools, and a philosophy.
It is an ideal means for thinking because it corresponds to the way our minds
work. Thinking Forth is thinking simple, thinking elegant, thinking flexible.

The mechanism that produces this effect is
Forth’s data stack. Forth automatically pushes numbers onto the stack; words
that require numbers as input automatically pop them off the stack; words
that produce numbers as output automatically push them onto the stack.

Because Forth uses a stack for passing data, words can nest within words.
Any word can put numbers on the stack and take them off without upsetting
the f1ow of data between words at a higher level (provided, of course, that the
word doesn’t consume or leave any unexpected values). Thus the stack supports
structured, modular programming while providing a simple mechanism
for passing local arguments.

If Forth code is really well-written, there should be nothing ambiguous
about it. This means that:
• supporting lexicons have a well-designed syntax
• stack inputs and outputs are commented
• the purpose is commented (if it’s not clear from the name or stack comment)
• definitions are not too long
• not too many arguments are passed to a single definition via the stack.

One important result of this approach: Arguments are unnamed. They reside
on the stack, not in named variables. This effect is one of the reasons for Forth’s
elegance. At the same time it’s one of the reasons badly written Forth code
can be unreadable.

Simplify code by using the stack. But don’t stack too deeply within any single
definition. Redesign, or, as a last resort, use a named variable.

Some folks like the words PICK and ROLL. They use these words to access
elements from any level on the stack. We don’t recommend them. For one
thing, PICK and ROLL encourage the programmer to think of the stack as an
array, which it is not. If you have so many elements on the stack that you need
PICK and ROLL, those elements should be in an array instead.
Second, they encourage the programmer to refer to arguments that have
been left on the stack by higher-level, calling definitions without being explicitly
On PICK and ROLL passed as arguments. This makes the definition dependent
on other definitions. That’s unstructured—and dangerous."

Hans Bezemer

Re: Not really locals

<shn2on$1jif$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 18:39:52 +1000
Organization: Aioe.org NNTP Server
Message-ID: <shn2on$1jif$1@gioia.aioe.org>
References: <shapgj$1a32$1@gioia.aioe.org>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <2021Sep11.083507@mips.complang.tuwien.ac.at>
<3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com>
<2021Sep12.123956@mips.complang.tuwien.ac.at> <87bl4x7axr.fsf@nightsong.com>
<36c1eba4-3433-4e29-b5b7-347832787406n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="52815"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Mon, 13 Sep 2021 08:39 UTC

On 13/09/2021 17:34, Hans Bezemer wrote:
>
> There is a reason you won't find anything on locals, because it violates its
> basic philosophy ("stamp out the variables").
>
> I've taken the liberty to pick some quotes from it. Of course, this opens up
> attacks like "cherry picking", but if you think so, go cherry picking yourself.

I rather like this one which is an appeal to use the mechanism Forth provides:

"Programmers unaccustomed to a language in which data can be passed implicitly
don’t always utilize the stack as fully as they should."

Sadly the Hayes' syntax has normalized locals use in Forth. After all, one
can't get simpler than a stack comment. An illusion which worked so well
that when ANS announced their syntax, objectors screamed the locals were in
reverse order! Never mind this was Forth which uses a LIFO stack. These
were but subtleties locals could - and should - abstract away.

Re: Not really locals

<2021Sep13.120158@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 10:01:58 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 34
Message-ID: <2021Sep13.120158@mips.complang.tuwien.ac.at>
References: <shapgj$1a32$1@gioia.aioe.org> <163128058713.22831.15524277815532345443@media.vsta.org> <35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at> <2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com> <87k0jm6zou.fsf@nightsong.com> <2021Sep12.132752@mips.complang.tuwien.ac.at> <87lf4157xc.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="adc1cc9999d4f6f902b7838f9a4a2636";
logging-data="4569"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KQvqtPvkmXgid6OcUZGk6"
Cancel-Lock: sha1:BtEj9AMS6n5+JIOVIxXm+InV6is=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 13 Sep 2021 10:01 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> There are more optimal ways, and I can look them up if you want, but
>> they are not simpler.
>
>At the moment I think I need "simple", but thanks ;-).

You can find some more discussion of the simple approach in section
4.4.1 of

@InProceedings{ertl&pirker97,
author = {M. Anton Ertl and Christian Pirker},
title = {The Structure of a {Forth} Native Code Compiler},
booktitle = {EuroForth '97 Conference Proceedings},
year = {1997},
address = {Oxford},
pages = {107--116},
url = {http://www.complang.tuwien.ac.at/papers/ertl%26pirker97.ps.gz},
abstract = {Writing a sophisticated Forth native code compiler
poses some tasks that are not discussed in compiler
text books. Some of these tasks arise from specific
language features, others from the requirement for
very fast compilation to maintain interactivity. In
this paper we describe some of the more interesting
data structures and algorithms used in the RAFTS
prototype.}
}

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

Re: Not really locals

<2021Sep13.121933@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Mon, 13 Sep 2021 10:19:33 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 22
Message-ID: <2021Sep13.121933@mips.complang.tuwien.ac.at>
References: <shapgj$1a32$1@gioia.aioe.org> <35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at> <2021Sep11.222320@mips.complang.tuwien.ac.at> <9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com> <87k0jm6zou.fsf@nightsong.com> <d7c85a4e-65fd-4460-bfbd-af81d3d6e55bn@googlegroups.com> <87pmtd58vd.fsf@nightsong.com> <4f087736-7f20-4390-9c2a-1f3fd41c0ab7n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="adc1cc9999d4f6f902b7838f9a4a2636";
logging-data="4569"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19h3Hmx46i360j7WrRX2gOt"
Cancel-Lock: sha1:tZnneoVCFGNcB+zYZyU3M7Ddo3M=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 13 Sep 2021 10:19 UTC

P Falth <peter.m.falth@gmail.com> writes:
>For lxf64 I tried loading the assembler
>from gforth. It doubled the size of my forth imagefile!. lxf64 compiles
>a complete forth2012 compliant system in an image file of 46k bytes.
>But now instead i have 2.5MB dll for assembler and 1.5 MB for disassembler

:-) For comparison, in gforth-fast AMD64 we see the following number
of bytes:

data+
threaded native
58720 34524 asm.fs
98616 38552 disasm.fs

And I am sure it is smaller on lxf.

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

Re: Not really locals

<86d38fed-d7e3-4b75-a1eb-d693bd39c70en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:f304:: with SMTP id p4mr151504qkg.334.1631546623965;
Mon, 13 Sep 2021 08:23:43 -0700 (PDT)
X-Received: by 2002:a0c:e0c7:: with SMTP id x7mr11043810qvk.55.1631546623776;
Mon, 13 Sep 2021 08:23:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 13 Sep 2021 08:23:43 -0700 (PDT)
In-Reply-To: <87bl4x7axr.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:482f:e0f2:4548:8489;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:482f:e0f2:4548:8489
References: <shapgj$1a32$1@gioia.aioe.org> <6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com> <87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com> <163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com>
<2021Sep11.083507@mips.complang.tuwien.ac.at> <3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com>
<2021Sep12.123956@mips.complang.tuwien.ac.at> <87bl4x7axr.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <86d38fed-d7e3-4b75-a1eb-d693bd39c70en@googlegroups.com>
Subject: Re: Not really locals
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Mon, 13 Sep 2021 15:23:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 12
 by: S Jack - Mon, 13 Sep 2021 15:23 UTC

On Sunday, September 12, 2021 at 4:15:13 PM UTC-5, Paul Rubin wrote:
> crystallized into a concrete example. The trouble is that multiple
> readers will have different interpretations and won't always come away
> with the same lesson. There is a whole industry of literary criticism

In Stephen Donaldson's Lord Foul's Bane two characters are conversing.
The dialog is shown so what is being said and what is heard is seen
but also shown in the mind of each character the dialog is interpreted
differently. The two think they are on the same page and the dialog
appears to corroborate it but in actuality the two characters are 180
out. Thus is the nature of the spoken or written language.
--
me

Re: Not really locals

<a32c9ed3-3255-4d3e-ad40-5a453d3fbfa7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:71ca:: with SMTP id i10mr232968qtp.62.1631547518164;
Mon, 13 Sep 2021 08:38:38 -0700 (PDT)
X-Received: by 2002:ac8:13c6:: with SMTP id i6mr205853qtj.248.1631547517998;
Mon, 13 Sep 2021 08:38:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 13 Sep 2021 08:38:37 -0700 (PDT)
In-Reply-To: <87fsu97bgc.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:482f:e0f2:4548:8489;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:482f:e0f2:4548:8489
References: <shapgj$1a32$1@gioia.aioe.org> <6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com> <87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com> <163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com>
<shibtq$16uo$1@gioia.aioe.org> <2021Sep11.215052@mips.complang.tuwien.ac.at>
<871r5u936m.fsf@nightsong.com> <2021Sep12.105636@mips.complang.tuwien.ac.at>
<shknb5$15fl$1@gioia.aioe.org> <87fsu97bgc.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a32c9ed3-3255-4d3e-ad40-5a453d3fbfa7n@googlegroups.com>
Subject: Re: Not really locals
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Mon, 13 Sep 2021 15:38:38 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 9
 by: S Jack - Mon, 13 Sep 2021 15:38 UTC

On Sunday, September 12, 2021 at 4:04:05 PM UTC-5, Paul Rubin wrote:
> Forth after all was historically a straightforwardly implemented,
> interpreted language, that was faster than other interpreted languages
> like BASIC. If your program had a speed bottleneck you'd handle that by
> writing CODE words.

That's why I started and the simplicity still appeals to me.
As long as I can beat Basic I'm happy.
--
me

Re: Not really locals

<630b1406-de75-45e8-b768-41d5f05b7447n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:74b:: with SMTP id k11mr243465qth.46.1631547768684; Mon, 13 Sep 2021 08:42:48 -0700 (PDT)
X-Received: by 2002:a05:620a:9c9:: with SMTP id y9mr211262qky.207.1631547768529; Mon, 13 Sep 2021 08:42:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder5.feed.usenet.farm!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 13 Sep 2021 08:42:48 -0700 (PDT)
In-Reply-To: <86d38fed-d7e3-4b75-a1eb-d693bd39c70en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f0f:8f91:16a:bc70:aeb6:b83b; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f0f:8f91:16a:bc70:aeb6:b83b
References: <shapgj$1a32$1@gioia.aioe.org> <6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com> <856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com> <87k0jpr6sd.fsf@nightsong.com> <1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com> <163128058713.22831.15524277815532345443@media.vsta.org> <35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com> <87czpf8yfc.fsf@nightsong.com> <2021Sep11.083507@mips.complang.tuwien.ac.at> <3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com> <2021Sep12.123956@mips.complang.tuwien.ac.at> <87bl4x7axr.fsf@nightsong.com> <86d38fed-d7e3-4b75-a1eb-d693bd39c70en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <630b1406-de75-45e8-b768-41d5f05b7447n@googlegroups.com>
Subject: Re: Not really locals
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 13 Sep 2021 15:42:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: minf...@arcor.de - Mon, 13 Sep 2021 15:42 UTC

S Jack schrieb am Montag, 13. September 2021 um 17:23:44 UTC+2:
> On Sunday, September 12, 2021 at 4:15:13 PM UTC-5, Paul Rubin wrote:
> > crystallized into a concrete example. The trouble is that multiple
> > readers will have different interpretations and won't always come away
> > with the same lesson. There is a whole industry of literary criticism
> In Stephen Donaldson's Lord Foul's Bane two characters are conversing.
> The dialog is shown so what is being said and what is heard is seen
> but also shown in the mind of each character the dialog is interpreted
> differently. The two think they are on the same page and the dialog
> appears to corroborate it but in actuality the two characters are 180
> out. Thus is the nature of the spoken or written language.

It's just another example for Plato's allegory of the cave.

But computer languages have well-defined syntax and should have well-
defined semantics, and perhaps should work only in Turing-complete systems.
Alas in reality UB is everywhere....

Re: Not really locals

<shoups$52g$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Tue, 14 Sep 2021 11:44:27 +1000
Organization: Aioe.org NNTP Server
Message-ID: <shoups$52g$1@gioia.aioe.org>
References: <shapgj$1a32$1@gioia.aioe.org>
<6a752f87-db15-4fd6-bf0b-c26df8e294den@googlegroups.com>
<856ed583-8868-43db-9059-7d1eb8754e02n@googlegroups.com>
<87k0jpr6sd.fsf@nightsong.com>
<1edac439-8805-4283-b64c-7f1490a53277n@googlegroups.com>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <2021Sep11.083507@mips.complang.tuwien.ac.at>
<3255ae60-2ba6-43b3-b1e6-7edf7031a4e6n@googlegroups.com>
<2021Sep12.123956@mips.complang.tuwien.ac.at> <87bl4x7axr.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="5200"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Tue, 14 Sep 2021 01:44 UTC

On 13/09/2021 07:15, Paul Rubin wrote:
>
> Here, Hans Bezemer has advised me to read Thinking Forth in order to
> receive a philosophical lesson about the evils of locals. I'm open to
> having such an experience, but I have read the book before and looked at
> it again last night, and that particular point didn't come across to me
> either time.

When Brodie wrote his book in 1984, locals were barely known, appearing
alongside off-beat topics in FD. To say there's no mention of locals in
Thinking Forth was a reflection of the times. What was evident then, was
folks writing code with lots of temporary variables just as they might
write it in C - and this was discussed in the book.
Locals came into public consciousness with ANS' endorsement. ANS was
establishment and, apart from Moore, nobody challenged establishment.
It's only with the crumbling of ANS and its subsequent hi-jacking that
questions are once again being asked.

Re: Not really locals

<87h7en54m6.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Not really locals
Date: Tue, 14 Sep 2021 12:39:13 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <87h7en54m6.fsf@nightsong.com>
References: <shapgj$1a32$1@gioia.aioe.org>
<163128058713.22831.15524277815532345443@media.vsta.org>
<35ca7585-5e60-451e-af03-f6681fb19570n@googlegroups.com>
<87czpf8yfc.fsf@nightsong.com> <shibtq$16uo$1@gioia.aioe.org>
<2021Sep11.215052@mips.complang.tuwien.ac.at>
<2021Sep11.222320@mips.complang.tuwien.ac.at>
<9460b63b-1e3a-40e9-ba7d-b9b6bcb22a1dn@googlegroups.com>
<87k0jm6zou.fsf@nightsong.com>
<2021Sep12.132752@mips.complang.tuwien.ac.at>
<87lf4157xc.fsf@nightsong.com>
<2021Sep13.120158@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="986bde19cb88afc80a6a0fe76ce7b0e4";
logging-data="14785"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zt/4EumMo+T+N/M7PuBa7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:qN/HfXOwXp2tRWPV5dsrYfObjRw=
sha1:jlc6myfSkNVH9PVAldGu0zZQNRg=
 by: Paul Rubin - Tue, 14 Sep 2021 19:39 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> You can find some more discussion of the simple approach in section
> 4.4.1 of
> author = {M. Anton Ertl and Christian Pirker},
> title = {The Structure of a {Forth} Native Code Compiler},

Thanks, this is a good paper and I will try to digest it. One remaining
issue is the difference between a native code compiler, and one that
targets a bytecode VM for purposes of maximizing code density. I
remember reading that on 32-bit targets, native code turned out to be
denser than traditional threaded code, so the transition from 16 bit to
32 bit hardware brought with it a transition to native code, e.g. in
SwiftForth. Bytecode didn't come into consideration because of the
resulting slowdown, and the relative abundance of memory on those
targets.

On an 8-bit target with 16-bit Forth cells, I think I really have to use
bytecode, since otherwise even simple arithmetic or stack operations
take multiple instructions. Traditional bytecode VM's for Forth are
simple stack machines with primitives for common Forth words like DUP,
SWAP, etc. But if the VM is a compiler target, it may be better to
design it in conjunction with the compiler. For example, maybe it
should have registers that the compiler can use.

I'm surprised this type of question has not gotten more attention in the
Forth world, given the long association between Forth and memory starved
targets.

Pages:1234567
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor