Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

<moshez> ok, I will not marry Jo-Con-El's cow.


devel / comp.lang.forth / ESP32Forth big bug with FOR..NEXT loop ...???

SubjectAuthor
* ESP32Forth big bug with FOR..NEXT loop ...???Marc Petremann
+- Re: ESP32Forth big bug with FOR..NEXT loop ...???Stephen Pelc
+- Re: ESP32Forth big bug with FOR..NEXT loop ...???dxforth
+- Re: ESP32Forth big bug with FOR..NEXT loop ...???Anton Ertl
+- Re: ESP32Forth big bug with FOR..NEXT loop ...???Hans Bezemer
+* Re: ESP32Forth big bug with FOR..NEXT loop ...???Marcel Hendrix
|`* Re: ESP32Forth big bug with FOR..NEXT loop ...???Rick C
| +* Re: ESP32Forth big bug with FOR..NEXT loop ...???minf...@arcor.de
| |+* Re: ESP32Forth big bug with FOR..NEXT loop ...???Kerr-Mudd, John
| ||`- Re: ESP32Forth big bug with FOR..NEXT loop ...???minf...@arcor.de
| |`- Re: ESP32Forth big bug with FOR..NEXT loop ...???Anton Ertl
| `* Re: ESP32Forth big bug with FOR..NEXT loop ...???dxforth
|  `* Re: ESP32Forth big bug with FOR..NEXT loop ...???Rick C
|   `* Re: ESP32Forth big bug with FOR..NEXT loop ...???dxforth
|    `* Re: ESP32Forth big bug with FOR..NEXT loop ...???Rick C
|     +* Re: ESP32Forth big bug with FOR..NEXT loop ...???minf...@arcor.de
|     |`* Re: ESP32Forth big bug with FOR..NEXT loop ...???dxforth
|     | `- Re: ESP32Forth big bug with FOR..NEXT loop ...???dxforth
|     `* Re: ESP32Forth big bug with FOR..NEXT loop ...???dxforth
|      `* Re: ESP32Forth big bug with FOR..NEXT loop ...???Rick C
|       +* Re: ESP32Forth big bug with FOR..NEXT loop ...???minf...@arcor.de
|       |`- Re: ESP32Forth big bug with FOR..NEXT loop ...???Marcel Hendrix
|       `- Re: ESP32Forth big bug with FOR..NEXT loop ...???dxforth
+- Re: ESP32Forth big bug with FOR..NEXT loop ...???Marc Petremann
`* Re: ESP32Forth big bug with FOR..NEXT loop ...???Mike
 `* Re: ESP32Forth big bug with FOR..NEXT loop ...???Rick C
  `* Re: ESP32Forth big bug with FOR..NEXT loop ...???Mike
   `- Re: ESP32Forth big bug with FOR..NEXT loop ...???Rick C

Pages:12
ESP32Forth big bug with FOR..NEXT loop ...???

<db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:9684:: with SMTP id y126mr4508336qkd.766.1644750764161;
Sun, 13 Feb 2022 03:12:44 -0800 (PST)
X-Received: by 2002:ac8:5317:: with SMTP id t23mr6361240qtn.508.1644750764008;
Sun, 13 Feb 2022 03:12:44 -0800 (PST)
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, 13 Feb 2022 03:12:43 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=90.37.206.228; posting-account=xbxuywoAAAASFWsQBmiz40gnxDBWDrxx
NNTP-Posting-Host: 90.37.206.228
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Subject: ESP32Forth big bug with FOR..NEXT loop ...???
From: mpetrema...@gmail.com (Marc Petremann)
Injection-Date: Sun, 13 Feb 2022 11:12:44 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 18
 by: Marc Petremann - Sun, 13 Feb 2022 11:12 UTC

I'm using ESP32Forth v v7.0.6.14

I have a (BIG) problem with FOR NEXT loop....

A simple example:

: myLoop

5 for r@ . next ;

display 5 4 3 2 1 0

So, 6 iterations !!!

And not 5 iterations as attempted....

Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations

BR

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<suarv9$a87$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: step...@vfxforth.com (Stephen Pelc)
Newsgroups: comp.lang.forth
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Sun, 13 Feb 2022 12:01:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <suarv9$a87$1@dont-email.me>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 13 Feb 2022 12:01:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c62082590679a1ff41008a3fd2427dfe";
logging-data="10503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WHCBB3ic7o4WC/ftZPrbT"
User-Agent: Usenapp/1.17/l for MacOS - Full License
Cancel-Lock: sha1:YcvE68RlSm+Ui3llP+DioDfzsfI=
 by: Stephen Pelc - Sun, 13 Feb 2022 12:01 UTC

On 13 Feb 2022 at 12:12:43 CET, "Marc Petremann" <mpetremann93m@gmail.com>
wrote:

> I'm using ESP32Forth v v7.0.6.14
>
> I have a (BIG) problem with FOR NEXT loop....

Now you know why standards are important. They help to avoid (BIG) problems.

Why not write a proposal for FOR ... NEXT and submit it to forth-standard.org.

Stephen

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

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<suasos$qhu$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.freedyn.de!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Sun, 13 Feb 2022 23:15:25 +1100
Organization: Aioe.org NNTP Server
Message-ID: <suasos$qhu$1@gioia.aioe.org>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="27198"; 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:91.0) Gecko/20100101
Thunderbird/91.6.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Sun, 13 Feb 2022 12:15 UTC

On 13/02/2022 22:12, Marc Petremann wrote:
> I'm using ESP32Forth v v7.0.6.14
>
> I have a (BIG) problem with FOR NEXT loop....
>
> A simple example:
>
> : myLoop
>
> 5 for r@ . next ;
>
> display 5 4 3 2 1 0
>
> So, 6 iterations !!!
>
> And not 5 iterations as attempted....
>
> Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations

They differ too ...

Gforth 0.7.9_20200709

: t for r@ . next ; ok
5 t 5 4 3 2 1 0 ok
0 t 0 ok

E FlashForth 5 ATmega328P

: t for r@ . next ; ok<#,ram>
5 t 4 3 2 1 0 ok<#,ram>
0 t ok<#,ram>

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<2022Feb13.133653@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!paganini.bofh.team!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: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Sun, 13 Feb 2022 12:36:53 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 27
Message-ID: <2022Feb13.133653@mips.complang.tuwien.ac.at>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="c34096716f8b683cb9eb00b0696c2846";
logging-data="23667"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UbC2GX80m3l96F1IFpD9S"
Cancel-Lock: sha1:AoEmTvPsRRghyB4SbwvsgPv7waU=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 13 Feb 2022 12:36 UTC

Marc Petremann <mpetremann93m@gmail.com> writes:
>I'm using ESP32Forth v v7.0.6.14
>
>I have a (BIG) problem with FOR NEXT loop....
>
>A simple example:
>
>: myLoop
>
> 5 for r@ . next ;
>
>display 5 4 3 2 1 0
>
>So, 6 iterations !!!
>
>And not 5 iterations as attempted....
>
>Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations

There is no common practice for FOR..NEXT. USE ?DO..LOOP instead!

- 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: ESP32Forth big bug with FOR..NEXT loop ...???

<b1b8f92e-5bc0-4df9-afb3-fb9aee5987ddn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5e08:: with SMTP id h8mr6665534qtx.655.1644758912220;
Sun, 13 Feb 2022 05:28:32 -0800 (PST)
X-Received: by 2002:a05:620a:1645:: with SMTP id c5mr4798735qko.609.1644758912068;
Sun, 13 Feb 2022 05:28:32 -0800 (PST)
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, 13 Feb 2022 05:28:31 -0800 (PST)
In-Reply-To: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b1b8f92e-5bc0-4df9-afb3-fb9aee5987ddn@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Sun, 13 Feb 2022 13:28:32 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 4
 by: Hans Bezemer - Sun, 13 Feb 2022 13:28 UTC

On Sunday, February 13, 2022 at 12:12:45 PM UTC+1, mpetre...@gmail.com wrote:
> I'm using ESP32Forth v v7.0.6.14
BTW, talking about ESP32 - how do you transfer stuff over the serial line (e.g. if you want to back up a block). Is there a kind of XMODEM implementation or what?

Hans Bezemer

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2405:: with SMTP id d5mr5197163qkn.534.1644766937528;
Sun, 13 Feb 2022 07:42:17 -0800 (PST)
X-Received: by 2002:a05:620a:94e:: with SMTP id w14mr5044875qkw.485.1644766937357;
Sun, 13 Feb 2022 07:42:17 -0800 (PST)
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, 13 Feb 2022 07:42:17 -0800 (PST)
In-Reply-To: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:7402:aac0:976e:44dc;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:7402:aac0:976e:44dc
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sun, 13 Feb 2022 15:42:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: Marcel Hendrix - Sun, 13 Feb 2022 15:42 UTC

On Sunday, February 13, 2022 at 12:12:45 PM UTC+1, mpetre...@gmail.com wrote:
> I'm using ESP32Forth v v7.0.6.14
> I have a (BIG) problem with FOR NEXT loop....
> A simple example:
>
> : myLoop
> 5 for r@ . next ;
> display 5 4 3 2 1 0
> So, 6 iterations !!!
> And not 5 iterations as attempted....
> Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
But it does make sense.

FORTH> help FOR
....
Each pass through the loop, the loop control parameter is tested
for zero. If it becomes zero the loop is exited, if it does not,
the control parameter is decremented by one. If the limit n|u is
0 to start with, one pass will be made. As this behavior is not
very useful, the FOR AFT ... THEN NEXT construct has gained
popularity.

FORTH> : test 5 for i@ . next ; test 5 4 3 2 1 0 ok
FORTH> : test2 5 for i . next ; test2 5 4 3 2 1 0 ok
FORTH> : test3 5 for r@ . next ; test3 5 4 3 2 1 0 ok

-marcel

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:1924:: with SMTP id bj36mr5203361qkb.526.1644774611560;
Sun, 13 Feb 2022 09:50:11 -0800 (PST)
X-Received: by 2002:a05:620a:1645:: with SMTP id c5mr5259501qko.609.1644774611306;
Sun, 13 Feb 2022 09:50:11 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 13 Feb 2022 09:50:11 -0800 (PST)
In-Reply-To: <c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com> <c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Sun, 13 Feb 2022 17:50:11 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Rick C - Sun, 13 Feb 2022 17:50 UTC

On Sunday, February 13, 2022 at 10:42:18 AM UTC-5, Marcel Hendrix wrote:
> On Sunday, February 13, 2022 at 12:12:45 PM UTC+1, mpetre...@gmail.com wrote:
> > I'm using ESP32Forth v v7.0.6.14
> > I have a (BIG) problem with FOR NEXT loop....
> > A simple example:
> >
> > : myLoop
> > 5 for r@ . next ;
> > display 5 4 3 2 1 0
> > So, 6 iterations !!!
> > And not 5 iterations as attempted....
> > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> But it does make sense.
>
> FORTH> help FOR
> ...
> Each pass through the loop, the loop control parameter is tested
> for zero. If it becomes zero the loop is exited, if it does not,
> the control parameter is decremented by one. If the limit n|u is
> 0 to start with, one pass will be made. As this behavior is not
> very useful, the FOR AFT ... THEN NEXT construct has gained
> popularity.
>
> FORTH> : test 5 for i@ . next ; test 5 4 3 2 1 0 ok
> FORTH> : test2 5 for i . next ; test2 5 4 3 2 1 0 ok
> FORTH> : test3 5 for r@ . next ; test3 5 4 3 2 1 0 ok

Since FOR is not part of the standard, the question is what is expected of FOR NEXT? I would like to see it streamlined as much as possible. So the decrement, test and jump should be integral since implementations can use efficient instructions for this. That would make it part of NEXT. In that case, you would get numbers printed from 5 down to 0 inclusive.

I assume the OP is looking for a match in range with DO where 5 0 DO i . LOOP would run for 0 1 2 3 4 but not 5. To do that in FOR NEXT it would require the decrement to be done first, the body of the loop executed, then the exit test done in NEXT. Or the loop can be arranged differently, but there would need to be two jumps, either one into a later point in the loop, or one for looping back and one for exiting the loop.

FOR NEXT is not DO LOOP. It counts in the other direction. If you consider the definition of DO with a negative index using +LOOP, I believe the two will count the same way since the exit condition is crossing the boundary between the loop limit and the loop limit minus one. When counting down this means the loop will be executed for 0 as well as 5 in the examples above and also by

: test 0 5 DO I . -1 +LOOP ; test 5 4 3 2 1 0 ok

So maybe the OP doesn't understand this is a consequence of using the same algorithm with a negative index?

I had not seen the FOR AFT THEN NEXT construct. I like it.

--

Rick C.

- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<f4b89e0b-2ded-4b18-8dc1-bba6dcda47bbn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:430d:: with SMTP id u13mr5344996qko.286.1644777933971;
Sun, 13 Feb 2022 10:45:33 -0800 (PST)
X-Received: by 2002:a05:620a:2912:: with SMTP id m18mr5402053qkp.227.1644777933808;
Sun, 13 Feb 2022 10:45:33 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 13 Feb 2022 10:45:33 -0800 (PST)
In-Reply-To: <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f4b89e0b-2ded-4b18-8dc1-bba6dcda47bbn@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Sun, 13 Feb 2022 18:45:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: minf...@arcor.de - Sun, 13 Feb 2022 18:45 UTC

gnuarm.del...@gmail.com schrieb am Sonntag, 13. Februar 2022 um 18:50:12 UTC+1:
> On Sunday, February 13, 2022 at 10:42:18 AM UTC-5, Marcel Hendrix wrote:
> > On Sunday, February 13, 2022 at 12:12:45 PM UTC+1, mpetre...@gmail.com wrote:
> > > I'm using ESP32Forth v v7.0.6.14
> > > I have a (BIG) problem with FOR NEXT loop....
> > > A simple example:
> > >
> > > : myLoop
> > > 5 for r@ . next ;
> > > display 5 4 3 2 1 0
> > > So, 6 iterations !!!
> > > And not 5 iterations as attempted....
> > > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> > But it does make sense.
> >
> > FORTH> help FOR
> > ...
> > Each pass through the loop, the loop control parameter is tested
> > for zero. If it becomes zero the loop is exited, if it does not,
> > the control parameter is decremented by one. If the limit n|u is
> > 0 to start with, one pass will be made. As this behavior is not
> > very useful, the FOR AFT ... THEN NEXT construct has gained
> > popularity.
> >
> > FORTH> : test 5 for i@ . next ; test 5 4 3 2 1 0 ok
> > FORTH> : test2 5 for i . next ; test2 5 4 3 2 1 0 ok
> > FORTH> : test3 5 for r@ . next ; test3 5 4 3 2 1 0 ok
> Since FOR is not part of the standard, the question is what is expected of FOR NEXT? I would like to see it streamlined as much as possible. So the decrement, test and jump should be integral since implementations can use efficient instructions for this. That would make it part of NEXT. In that case, you would get numbers printed from 5 down to 0 inclusive.
>

F.ex. match NEXT efficiently to x_86 processor LOOP instruction (counter in _CX register)
and you'll happily count down from 5 to 1.

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<20220213195242.93887ba969e8f7b9cbe4fc02@127.0.0.1>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: adm...@127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.forth
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Sun, 13 Feb 2022 19:52:42 +0000
Organization: Dis
Lines: 41
Message-ID: <20220213195242.93887ba969e8f7b9cbe4fc02@127.0.0.1>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>
<aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<f4b89e0b-2ded-4b18-8dc1-bba6dcda47bbn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="aa3dd7b6f10b6f5e98589520ea8d425f";
logging-data="10607"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Gi0RvAHs4+SbCFv7LOPLQVMDWBTVWqfE="
Cancel-Lock: sha1:hwzfLKLiLgDQPsCzLNGV8mwT7d0=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
;X-no-Archive: Maybe
GNU: Terry Pratchett
 by: Kerr-Mudd, John - Sun, 13 Feb 2022 19:52 UTC

On Sun, 13 Feb 2022 10:45:33 -0800 (PST)
"minf...@arcor.de" <minforth@arcor.de> wrote:

> gnuarm.del...@gmail.com schrieb am Sonntag, 13. Februar 2022 um 18:50:12 UTC+1:
> > On Sunday, February 13, 2022 at 10:42:18 AM UTC-5, Marcel Hendrix wrote:
> > > On Sunday, February 13, 2022 at 12:12:45 PM UTC+1, mpetre...@gmail.com wrote:
> > > > I'm using ESP32Forth v v7.0.6.14
> > > > I have a (BIG) problem with FOR NEXT loop....
> > > > A simple example:
> > > >
> > > > : myLoop
> > > > 5 for r@ . next ;
> > > > display 5 4 3 2 1 0
> > > > So, 6 iterations !!!
> > > > And not 5 iterations as attempted....
> > > > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> > > But it does make sense.
> > >
> > > FORTH> help FOR
> > > ...
> > > Each pass through the loop, the loop control parameter is tested
> > > for zero. If it becomes zero the loop is exited, if it does not,
> > > the control parameter is decremented by one. If the limit n|u is
> > > 0 to start with, one pass will be made. As this behavior is not
> > > very useful, the FOR AFT ... THEN NEXT construct has gained
> > > popularity.
> > >
> > > FORTH> : test 5 for i@ . next ; test 5 4 3 2 1 0 ok
> > > FORTH> : test2 5 for i . next ; test2 5 4 3 2 1 0 ok
> > > FORTH> : test3 5 for r@ . next ; test3 5 4 3 2 1 0 ok
> > Since FOR is not part of the standard, the question is what is expected of FOR NEXT? I would like to see it streamlined as much as possible. So the decrement, test and jump should be integral since implementations can use efficient instructions for this. That would make it part of NEXT. In that case, you would get numbers printed from 5 down to 0 inclusive.
> >
>
> F.ex. match NEXT efficiently to x_86 processor LOOP instruction (counter in _CX register)
> and you'll happily count down from 5 to 1.
>
But if cx=0 at start you'd perform the 'for' loop a large number of times; unless the code starts with
JCXZ end-loop-addr

--
Bah, and indeed Humbug.

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<1a307210-8890-44b9-9aaf-32c8a3e08459n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:268a:: with SMTP id gm10mr7445810qvb.61.1644783842252;
Sun, 13 Feb 2022 12:24:02 -0800 (PST)
X-Received: by 2002:a05:622a:13cb:: with SMTP id p11mr7534125qtk.210.1644783842072;
Sun, 13 Feb 2022 12:24:02 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!2.eu.feeder.erje.net!2.us.feeder.erje.net!feeder.erje.net!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: Sun, 13 Feb 2022 12:24:01 -0800 (PST)
In-Reply-To: <20220213195242.93887ba969e8f7b9cbe4fc02@127.0.0.1>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<f4b89e0b-2ded-4b18-8dc1-bba6dcda47bbn@googlegroups.com> <20220213195242.93887ba969e8f7b9cbe4fc02@127.0.0.1>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1a307210-8890-44b9-9aaf-32c8a3e08459n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Sun, 13 Feb 2022 20:24:02 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 52
 by: minf...@arcor.de - Sun, 13 Feb 2022 20:24 UTC

Kerr-Mudd, John schrieb am Sonntag, 13. Februar 2022 um 20:52:44 UTC+1:
> On Sun, 13 Feb 2022 10:45:33 -0800 (PST)
> "minf...@arcor.de" <minf...@arcor.de> wrote:
>
> > gnuarm.del...@gmail.com schrieb am Sonntag, 13. Februar 2022 um 18:50:12 UTC+1:
> > > On Sunday, February 13, 2022 at 10:42:18 AM UTC-5, Marcel Hendrix wrote:
> > > > On Sunday, February 13, 2022 at 12:12:45 PM UTC+1, mpetre...@gmail.com wrote:
> > > > > I'm using ESP32Forth v v7.0.6.14
> > > > > I have a (BIG) problem with FOR NEXT loop....
> > > > > A simple example:
> > > > >
> > > > > : myLoop
> > > > > 5 for r@ . next ;
> > > > > display 5 4 3 2 1 0
> > > > > So, 6 iterations !!!
> > > > > And not 5 iterations as attempted....
> > > > > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> > > > But it does make sense.
> > > >
> > > > FORTH> help FOR
> > > > ...
> > > > Each pass through the loop, the loop control parameter is tested
> > > > for zero. If it becomes zero the loop is exited, if it does not,
> > > > the control parameter is decremented by one. If the limit n|u is
> > > > 0 to start with, one pass will be made. As this behavior is not
> > > > very useful, the FOR AFT ... THEN NEXT construct has gained
> > > > popularity.
> > > >
> > > > FORTH> : test 5 for i@ . next ; test 5 4 3 2 1 0 ok
> > > > FORTH> : test2 5 for i . next ; test2 5 4 3 2 1 0 ok
> > > > FORTH> : test3 5 for r@ . next ; test3 5 4 3 2 1 0 ok
> > > Since FOR is not part of the standard, the question is what is expected of FOR NEXT? I would like to see it streamlined as much as possible. So the decrement, test and jump should be integral since implementations can use efficient instructions for this. That would make it part of NEXT. In that case, you would get numbers printed from 5 down to 0 inclusive.
> > >
> >
> > F.ex. match NEXT efficiently to x_86 processor LOOP instruction (counter in _CX register)
> > and you'll happily count down from 5 to 1.
> >
> But if cx=0 at start you'd perform the 'for' loop a large number of times; unless the code starts with
> JCXZ end-loop-addr
>

Yep, an endless source of fun in a 64 bit system ...

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<19fa9747-da90-491e-ae64-2557d1643369n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:258e:: with SMTP id fq14mr7806844qvb.69.1644786424949;
Sun, 13 Feb 2022 13:07:04 -0800 (PST)
X-Received: by 2002:a05:622a:87:: with SMTP id o7mr7540007qtw.38.1644786424803;
Sun, 13 Feb 2022 13:07:04 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!5.161.45.24.MISMATCH!2.us.feeder.erje.net!feeder.erje.net!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: Sun, 13 Feb 2022 13:07:04 -0800 (PST)
In-Reply-To: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=90.37.206.228; posting-account=xbxuywoAAAASFWsQBmiz40gnxDBWDrxx
NNTP-Posting-Host: 90.37.206.228
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <19fa9747-da90-491e-ae64-2557d1643369n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: mpetrema...@gmail.com (Marc Petremann)
Injection-Date: Sun, 13 Feb 2022 21:07:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 25
 by: Marc Petremann - Sun, 13 Feb 2022 21:07 UTC

Le dimanche 13 février 2022 à 12:12:45 UTC+1, Marc Petremann a écrit :
> I'm using ESP32Forth v v7.0.6.14
>
> I have a (BIG) problem with FOR NEXT loop....
>
> A simple example:
>
> : myLoop
>
> 5 for r@ . next ;
>
> display 5 4 3 2 1 0
>
> So, 6 iterations !!!
>
> And not 5 iterations as attempted....
>
> Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
>
> BR

I have replaced FOR..NEXT with DO..LOOP in my code:
https://github.com/MPETREMANN11/ESP32forth/blob/main/displays/SSD1306-5x8rusFonts.txt

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<2022Feb13.231208@mips.complang.tuwien.ac.at>

  copy mid

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

  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: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Sun, 13 Feb 2022 22:12:08 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 83
Message-ID: <2022Feb13.231208@mips.complang.tuwien.ac.at>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com> <c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com> <f4b89e0b-2ded-4b18-8dc1-bba6dcda47bbn@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="c34096716f8b683cb9eb00b0696c2846";
logging-data="30543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oss/iLTxPuNtc9Ovz5T4w"
Cancel-Lock: sha1:3iasCpVIFvIX++8hLk31DwOoBQA=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 13 Feb 2022 22:12 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
>gnuarm.del...@gmail.com schrieb am Sonntag, 13. Februar 2022 um 18:50:12 UT=
>C+1:
>> On Sunday, February 13, 2022 at 10:42:18 AM UTC-5, Marcel Hendrix wrote:=
>=20
>> > On Sunday, February 13, 2022 at 12:12:45 PM UTC+1, mpetre...@gmail.com =
>wrote:=20
>> > > I'm using ESP32Forth v v7.0.6.14=20
>> > > I have a (BIG) problem with FOR NEXT loop....=20
>> > > A simple example:=20
>> > >=20
>> > > : myLoop=20
>> > > 5 for r@ . next ;=20
>> > > display 5 4 3 2 1 0=20
>> > > So, 6 iterations !!!=20
>> > > And not 5 iterations as attempted....=20
>> > > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 =
>iterations=20
>> > But it does make sense.=20
>> >=20
>> > FORTH> help FOR=20
>> > ...=20
>> > Each pass through the loop, the loop control parameter is tested=20
>> > for zero. If it becomes zero the loop is exited, if it does not,=20
>> > the control parameter is decremented by one. If the limit n|u is=20
>> > 0 to start with, one pass will be made. As this behavior is not=20
>> > very useful, the FOR AFT ... THEN NEXT construct has gained=20
>> > popularity.=20
>> >=20
>> > FORTH> : test 5 for i@ . next ; test 5 4 3 2 1 0 ok=20
>> > FORTH> : test2 5 for i . next ; test2 5 4 3 2 1 0 ok=20
>> > FORTH> : test3 5 for r@ . next ; test3 5 4 3 2 1 0 ok
>> Since FOR is not part of the standard, the question is what is expected o=
>f FOR NEXT? I would like to see it streamlined as much as possible. So the =
>decrement, test and jump should be integral since implementations can use e=
>fficient instructions for this. That would make it part of NEXT. In that ca=
>se, you would get numbers printed from 5 down to 0 inclusive.=20
>>=20
>
>F.ex. match NEXT efficiently to x_86 processor LOOP instruction (counter in=
> _CX register)
>and you'll happily count down from 5 to 1.

Yes, but why would one do this? As we have established in an earlier
discussion (see below), the LOOP instruction is typically not faster
than a sequence of simpler instructions:

<2018Jun6.184616@mips.complang.tuwien.ac.at>:
|minforth@arcor.de writes:
|>FOR..NEXT matches easily with the x86 LOOP instruction and ECX as counter.
|>Should do speedy enough. ;-)
| |Have you measured it? I have
|<2017Mar14.183125@mips.complang.tuwien.ac.at>
|<2017Mar15.141411@mips.complang.tuwien.ac.at> and compared the
|following loops:
| |.L5: .L5:
| subq $1, %rax loop .L5
| jne .L5
| |I found that for these loops Sandy Bridge, Haswell, and Skylake take
|~4 cycles per iteration using LOOP, and 1-2 cycles per iteration when
|using jne.

<2018Jun7.141731@mips.complang.tuwien.ac.at>:
|cycles for 1000 iterations
| K10 Excavator Zen
|Phenom II Athlon X4 845 Ryzen 1600X
| 3021 1314 1051 loop
| 2020 1484 1051 sub; jne
| 2026 1489 1053 add; cmp; jne

There is no performance advantage on modern AMD and Intel CPUs for the
instruction LOOP over a good implementation of the Forth word LOOP (as
in the third example).

- 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: ESP32Forth big bug with FOR..NEXT loop ...???

<suc9a8$klp$1@gioia.aioe.org>

  copy mid

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

  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: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Mon, 14 Feb 2022 11:55:38 +1100
Organization: Aioe.org NNTP Server
Message-ID: <suc9a8$klp$1@gioia.aioe.org>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>
<aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="21177"; 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:91.0) Gecko/20100101
Thunderbird/91.6.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 14 Feb 2022 00:55 UTC

On 14/02/2022 04:50, Rick C wrote:
>
> I had not seen the FOR AFT THEN NEXT construct. I like it.
Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
to 'fix it' which made it as complicated as DO LOOP but not as useful.

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:df85:: with SMTP id t127mr6001656qkf.744.1644812714667;
Sun, 13 Feb 2022 20:25:14 -0800 (PST)
X-Received: by 2002:a05:620a:4093:: with SMTP id f19mr6115917qko.306.1644812714477;
Sun, 13 Feb 2022 20:25:14 -0800 (PST)
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, 13 Feb 2022 20:25:14 -0800 (PST)
In-Reply-To: <suc9a8$klp$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Mon, 14 Feb 2022 04:25:14 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: Rick C - Mon, 14 Feb 2022 04:25 UTC

On Sunday, February 13, 2022 at 7:55:38 PM UTC-5, dxforth wrote:
> On 14/02/2022 04:50, Rick C wrote:
> >
> > I had not seen the FOR AFT THEN NEXT construct. I like it.
> Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
> to 'fix it' which made it as complicated as DO LOOP but not as useful.

Exactly which quirks where those?

--

Rick C.

+ Get 1,000 miles of free Supercharging
+ Tesla referral code - https://ts.la/richard11209

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<sud41q$1ba8$1@gioia.aioe.org>

  copy mid

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

  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: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Mon, 14 Feb 2022 19:31:56 +1100
Organization: Aioe.org NNTP Server
Message-ID: <sud41q$1ba8$1@gioia.aioe.org>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>
<aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org>
<45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="44360"; 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:91.0) Gecko/20100101
Thunderbird/91.6.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 14 Feb 2022 08:31 UTC

On 14/02/2022 15:25, Rick C wrote:
> On Sunday, February 13, 2022 at 7:55:38 PM UTC-5, dxforth wrote:
>> On 14/02/2022 04:50, Rick C wrote:
>> >
>> > I had not seen the FOR AFT THEN NEXT construct. I like it.
>> Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
>> to 'fix it' which made it as complicated as DO LOOP but not as useful.
>
> Exactly which quirks where those?

Loops n+1 times and n=0 isn't a NOOP. Not the behaviour one usually wants.

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:1109:: with SMTP id e9mr8678897qty.290.1644831632833;
Mon, 14 Feb 2022 01:40:32 -0800 (PST)
X-Received: by 2002:a05:6214:258e:: with SMTP id fq14mr8921466qvb.69.1644831632616;
Mon, 14 Feb 2022 01:40:32 -0800 (PST)
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, 14 Feb 2022 01:40:32 -0800 (PST)
In-Reply-To: <sud41q$1ba8$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org> <45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
<sud41q$1ba8$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Mon, 14 Feb 2022 09:40:32 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 21
 by: Rick C - Mon, 14 Feb 2022 09:40 UTC

On Monday, February 14, 2022 at 3:31:58 AM UTC-5, dxforth wrote:
> On 14/02/2022 15:25, Rick C wrote:
> > On Sunday, February 13, 2022 at 7:55:38 PM UTC-5, dxforth wrote:
> >> On 14/02/2022 04:50, Rick C wrote:
> >> >
> >> > I had not seen the FOR AFT THEN NEXT construct. I like it.
> >> Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
> >> to 'fix it' which made it as complicated as DO LOOP but not as useful.
> >
> > Exactly which quirks where those?
> Loops n+1 times and n=0 isn't a NOOP. Not the behaviour one usually wants.

That is exactly what DO +LOOP does with a negative index. It works fine for me. Addressing, such as in arrays, works exactly that way. You just need to subtract 1 from N before starting the loop to address n-1 down to 0.

Considering that FOR NEXT only decrements by 1, it seems logical to me for it to work this way.

--

Rick C.

-- Get 1,000 miles of free Supercharging
-- Tesla referral code - https://ts.la/richard11209

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<866bc645-bc2c-4151-b554-c995b4c13d5an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5711:: with SMTP id 17mr8689566qtw.287.1644833241052;
Mon, 14 Feb 2022 02:07:21 -0800 (PST)
X-Received: by 2002:a05:6214:1c8f:: with SMTP id ib15mr9025809qvb.2.1644833240880;
Mon, 14 Feb 2022 02:07:20 -0800 (PST)
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, 14 Feb 2022 02:07:20 -0800 (PST)
In-Reply-To: <0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org> <45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
<sud41q$1ba8$1@gioia.aioe.org> <0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <866bc645-bc2c-4151-b554-c995b4c13d5an@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 14 Feb 2022 10:07:21 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 21
 by: minf...@arcor.de - Mon, 14 Feb 2022 10:07 UTC

gnuarm.del...@gmail.com schrieb am Montag, 14. Februar 2022 um 10:40:33 UTC+1:
> On Monday, February 14, 2022 at 3:31:58 AM UTC-5, dxforth wrote:
> > On 14/02/2022 15:25, Rick C wrote:
> > > On Sunday, February 13, 2022 at 7:55:38 PM UTC-5, dxforth wrote:
> > >> On 14/02/2022 04:50, Rick C wrote:
> > >> >
> > >> > I had not seen the FOR AFT THEN NEXT construct. I like it.
> > >> Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
> > >> to 'fix it' which made it as complicated as DO LOOP but not as useful.
> > >
> > > Exactly which quirks where those?
> > Loops n+1 times and n=0 isn't a NOOP. Not the behaviour one usually wants.
> That is exactly what DO +LOOP does with a negative index. It works fine for me. Addressing, such as in arrays, works exactly that way. You just need to subtract 1 from N before starting the loop to address n-1 down to 0.
>
> Considering that FOR NEXT only decrements by 1, it seems logical to me for it to work this way.
>

FWIW apart from FOR .. NEXT, I use the following array walking words:
FOR> ( start number elementwidth -- ) walk forward, N yields the element address
<FOR ( start number elementwidth -- ) walk backwards, N yields the element address

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<sudai2$j8j$1@gioia.aioe.org>

  copy mid

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

  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: ESP32Forth big bug with FOR..NEXT loop ...???
Date: Mon, 14 Feb 2022 21:22:57 +1100
Organization: Aioe.org NNTP Server
Message-ID: <sudai2$j8j$1@gioia.aioe.org>
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com>
<aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org>
<45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
<sud41q$1ba8$1@gioia.aioe.org>
<0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="19731"; 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:91.0) Gecko/20100101
Thunderbird/91.6.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 14 Feb 2022 10:22 UTC

On 14/02/2022 20:40, Rick C wrote:
> On Monday, February 14, 2022 at 3:31:58 AM UTC-5, dxforth wrote:
>> On 14/02/2022 15:25, Rick C wrote:
>> > On Sunday, February 13, 2022 at 7:55:38 PM UTC-5, dxforth wrote:
>> >> On 14/02/2022 04:50, Rick C wrote:
>> >> >
>> >> > I had not seen the FOR AFT THEN NEXT construct. I like it.
>> >> Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
>> >> to 'fix it' which made it as complicated as DO LOOP but not as useful.
>> >
>> > Exactly which quirks where those?
>> Loops n+1 times and n=0 isn't a NOOP. Not the behaviour one usually wants.
>
> That is exactly what DO +LOOP does with a negative index. It works fine for me.

Luckily such instances are rare.

> Addressing, such as in arrays, works exactly that way. You just need to subtract 1 from N before starting the loop to address n-1 down to 0.
>
> Considering that FOR NEXT only decrements by 1, it seems logical to me for it to work this way.
>

Not according to eForth, FlashForth etc who developed workarounds for the behaviour.

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<fb8a22d9-21e5-4905-b839-ab557079c883n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:e889:: with SMTP id a131mr6593054qkg.771.1644835565278;
Mon, 14 Feb 2022 02:46:05 -0800 (PST)
X-Received: by 2002:a05:622a:1387:: with SMTP id o7mr5084600qtk.535.1644835565077;
Mon, 14 Feb 2022 02:46:05 -0800 (PST)
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, 14 Feb 2022 02:46:04 -0800 (PST)
In-Reply-To: <sudai2$j8j$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org> <45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
<sud41q$1ba8$1@gioia.aioe.org> <0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>
<sudai2$j8j$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fb8a22d9-21e5-4905-b839-ab557079c883n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Mon, 14 Feb 2022 10:46:05 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 29
 by: Rick C - Mon, 14 Feb 2022 10:46 UTC

On Monday, February 14, 2022 at 5:23:03 AM UTC-5, dxforth wrote:
> On 14/02/2022 20:40, Rick C wrote:
> > On Monday, February 14, 2022 at 3:31:58 AM UTC-5, dxforth wrote:
> >> On 14/02/2022 15:25, Rick C wrote:
> >> > On Sunday, February 13, 2022 at 7:55:38 PM UTC-5, dxforth wrote:
> >> >> On 14/02/2022 04:50, Rick C wrote:
> >> >> >
> >> >> > I had not seen the FOR AFT THEN NEXT construct. I like it.
> >> >> Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
> >> >> to 'fix it' which made it as complicated as DO LOOP but not as useful.
> >> >
> >> > Exactly which quirks where those?
> >> Loops n+1 times and n=0 isn't a NOOP. Not the behaviour one usually wants.
> >
> > That is exactly what DO +LOOP does with a negative index. It works fine for me.
> Luckily such instances are rare.
> > Addressing, such as in arrays, works exactly that way. You just need to subtract 1 from N before starting the loop to address n-1 down to 0.
> >
> > Considering that FOR NEXT only decrements by 1, it seems logical to me for it to work this way.
> >
> Not according to eForth, FlashForth etc who developed workarounds for the behaviour.

So? The thing about Forth is that everyone does what they personally prefer. Writing software is not the same as judging. There's nothing in either of these Forths that says FOR NEXT needs a work around. That's your judgement.

--

Rick C.

-+ Get 1,000 miles of free Supercharging
-+ Tesla referral code - https://ts.la/richard11209

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<8c704e5c-4be5-4918-8d21-e41097cd432an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:5181:: with SMTP id kl1mr9604860qvb.26.1644849826765;
Mon, 14 Feb 2022 06:43:46 -0800 (PST)
X-Received: by 2002:a05:622a:1387:: with SMTP id o7mr38863qtk.535.1644849826546;
Mon, 14 Feb 2022 06:43:46 -0800 (PST)
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, 14 Feb 2022 06:43:46 -0800 (PST)
In-Reply-To: <fb8a22d9-21e5-4905-b839-ab557079c883n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org> <45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
<sud41q$1ba8$1@gioia.aioe.org> <0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>
<sudai2$j8j$1@gioia.aioe.org> <fb8a22d9-21e5-4905-b839-ab557079c883n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8c704e5c-4be5-4918-8d21-e41097cd432an@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 14 Feb 2022 14:43:46 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 28
 by: minf...@arcor.de - Mon, 14 Feb 2022 14:43 UTC

gnuarm.del...@gmail.com schrieb am Montag, 14. Februar 2022 um 11:46:06 UTC+1:
> On Monday, February 14, 2022 at 5:23:03 AM UTC-5, dxforth wrote:
> > On 14/02/2022 20:40, Rick C wrote:
> > > On Monday, February 14, 2022 at 3:31:58 AM UTC-5, dxforth wrote:
> > >> On 14/02/2022 15:25, Rick C wrote:
> > >> > On Sunday, February 13, 2022 at 7:55:38 PM UTC-5, dxforth wrote:
> > >> >> On 14/02/2022 04:50, Rick C wrote:
> > >> >> >
> > >> >> > I had not seen the FOR AFT THEN NEXT construct. I like it.
> > >> >> Moore accepted FOR NEXT's quirks. Not so others - hence the various attempts
> > >> >> to 'fix it' which made it as complicated as DO LOOP but not as useful.
> > >> >
> > >> > Exactly which quirks where those?
> > >> Loops n+1 times and n=0 isn't a NOOP. Not the behaviour one usually wants.
> > >
> > > That is exactly what DO +LOOP does with a negative index. It works fine for me.
> > Luckily such instances are rare.
> > > Addressing, such as in arrays, works exactly that way. You just need to subtract 1 from N before starting the loop to address n-1 down to 0.
> > >
> > > Considering that FOR NEXT only decrements by 1, it seems logical to me for it to work this way.
> > >
> > Not according to eForth, FlashForth etc who developed workarounds for the behaviour.
> So? The thing about Forth is that everyone does what they personally prefer. Writing software is not the same as judging. There's nothing in either of these Forths that says FOR NEXT needs a work around. That's your judgement.
>

The thing with FOR .. NEXT is that it promises to not clutter the return stack
like DO/?DO .. LOOP. But when you nest words with FOR .. NEXT loops, you
have to save the index register nevertheless. So at the end of the day it does
not buy you much more than a prettier syntax.

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<c02da0a6-9730-49c5-a0ff-15d52b479342n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:29ce:: with SMTP id s14mr118716qkp.604.1644853252131;
Mon, 14 Feb 2022 07:40:52 -0800 (PST)
X-Received: by 2002:a05:622a:13cb:: with SMTP id p11mr302331qtk.210.1644853251923;
Mon, 14 Feb 2022 07:40:51 -0800 (PST)
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, 14 Feb 2022 07:40:51 -0800 (PST)
In-Reply-To: <8c704e5c-4be5-4918-8d21-e41097cd432an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:3d0b:1f1:ffc5:1ead;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:3d0b:1f1:ffc5:1ead
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<c9dec97f-7159-4e8e-8f35-ecd167451956n@googlegroups.com> <aefde187-f9c5-489a-954e-42006e3b6b9fn@googlegroups.com>
<suc9a8$klp$1@gioia.aioe.org> <45936395-77bd-42f6-8cc1-48edb942fc1an@googlegroups.com>
<sud41q$1ba8$1@gioia.aioe.org> <0d2c8841-190a-4328-8c42-6e38b1d148aen@googlegroups.com>
<sudai2$j8j$1@gioia.aioe.org> <fb8a22d9-21e5-4905-b839-ab557079c883n@googlegroups.com>
<8c704e5c-4be5-4918-8d21-e41097cd432an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c02da0a6-9730-49c5-a0ff-15d52b479342n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Mon, 14 Feb 2022 15:40:52 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 11
 by: Marcel Hendrix - Mon, 14 Feb 2022 15:40 UTC

On Monday, February 14, 2022 at 3:43:47 PM UTC+1, minf...@arcor.de wrote:
[..]
> The thing with FOR .. NEXT is that it promises to not clutter the return stack
> like DO/?DO .. LOOP. But when you nest words with FOR .. NEXT loops, you
> have to save the index register nevertheless. So at the end of the day it does
> not buy you much more than a prettier syntax.

I tried really hard to use it (it was in the iForth64 metacompiler as the exclusive
means of looping). I've abandoned it as DO LOOP is easier to remember and
get right (IMHO).

-marcel

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<db19b4f0-75a2-4b93-8d67-b72e1f072b67n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:192:: with SMTP id s18mr498662qtw.268.1644856481817;
Mon, 14 Feb 2022 08:34:41 -0800 (PST)
X-Received: by 2002:ac8:5317:: with SMTP id t23mr486906qtn.508.1644856481587;
Mon, 14 Feb 2022 08:34:41 -0800 (PST)
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, 14 Feb 2022 08:34:41 -0800 (PST)
In-Reply-To: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.94.110.221; posting-account=bfqVhAoAAABnxNiPDFL3mSrvM7YNO32Q
NNTP-Posting-Host: 87.94.110.221
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <db19b4f0-75a2-4b93-8d67-b72e1f072b67n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: oh2...@gmail.com (Mike)
Injection-Date: Mon, 14 Feb 2022 16:34:41 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: Mike - Mon, 14 Feb 2022 16:34 UTC

On Sunday, February 13, 2022 at 1:12:45 PM UTC+2, mpetre...@gmail.com wrote:
> I'm using ESP32Forth v v7.0.6.14
> I have a (BIG) problem with FOR NEXT loop....
> A simple example:
> : myLoop
> 5 for r@ . next ;
> display 5 4 3 2 1 0
> So, 6 iterations !!!
> And not 5 iterations as attempted....
> Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> BR
In hardware the simplest FOR NEXT implementation iterates at least one time.
But I wanted FlashForth to execute the loop as many times as requested,
and skip the loop if zero times is requested.
This is well aligned with my normal use cases in FlashForth and avoids
extra tests or adjustments before the loop. The index going from n-1 to 0
is well suited for indexing into a zero based array which is what I use a lot,
for example for running averages.
FOR is implemented so that it starts with jumping to NEXT to check if the index is zero,
if not zero NEXT jumps back to FOR (after the inital jump instruction).
The other implementations do not have this extra jump in the beginning and so they loop one extra time.

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<cee3f619-3b3f-4fe7-9351-a967ae36863dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:27ca:: with SMTP id ge10mr352439qvb.71.1644857398416;
Mon, 14 Feb 2022 08:49:58 -0800 (PST)
X-Received: by 2002:a05:6214:21a5:: with SMTP id t5mr356073qvc.51.1644857398174;
Mon, 14 Feb 2022 08:49:58 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!2.us.feeder.erje.net!feeder.erje.net!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, 14 Feb 2022 08:49:57 -0800 (PST)
In-Reply-To: <db19b4f0-75a2-4b93-8d67-b72e1f072b67n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com> <db19b4f0-75a2-4b93-8d67-b72e1f072b67n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cee3f619-3b3f-4fe7-9351-a967ae36863dn@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Mon, 14 Feb 2022 16:49:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 63
 by: Rick C - Mon, 14 Feb 2022 16:49 UTC

On Monday, February 14, 2022 at 11:34:42 AM UTC-5, Mike wrote:
> On Sunday, February 13, 2022 at 1:12:45 PM UTC+2, mpetre...@gmail.com wrote:
> > I'm using ESP32Forth v v7.0.6.14
> > I have a (BIG) problem with FOR NEXT loop....
> > A simple example:
> > : myLoop
> > 5 for r@ . next ;
> > display 5 4 3 2 1 0
> > So, 6 iterations !!!
> > And not 5 iterations as attempted....
> > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> > BR
> In hardware the simplest FOR NEXT implementation iterates at least one time.

What do you mean by this? A FOR NEXT loop is not exactly hardware. The hardware needs a counter that is decremented and the terminating condition is either reaching zero (internal =0 flag) or counting past zero (underflow or negative flag depending on data type). Depending on how you implement the details of the index numbers this can be at the beginning of the loop or the end. Put it at the beginning of the loop and you get N iterations including none for a starting count of zero. Put it at the end of the loop and you get N+1 iterations from N down to 0.

In all cases of the loop structure the number of iterations can be modified by jumping into the loop appropriately.

This all seems pretty simple and hardware independent to me. What are you thinking?

> But I wanted FlashForth to execute the loop as many times as requested,
> and skip the loop if zero times is requested.
> This is well aligned with my normal use cases in FlashForth and avoids
> extra tests or adjustments before the loop. The index going from n-1 to 0
> is well suited for indexing into a zero based array which is what I use a lot,
> for example for running averages.
> FOR is implemented so that it starts with jumping to NEXT to check if the index is zero,
> if not zero NEXT jumps back to FOR (after the inital jump instruction).

You mean check without decrementing? Does you loop exit when the index reaches zero or when zero is decremented below zero?

> The other implementations do not have this extra jump in the beginning and so they loop one extra time.

Horses for courses.

So if you are indexing a zero based array, how do you write code to handle 0 to N iterations?

--

Rick C.

+- Get 1,000 miles of free Supercharging
+- Tesla referral code - https://ts.la/richard11209

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<403b90d3-6893-4470-8147-4b7cfacad9c1n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:e889:: with SMTP id a131mr374538qkg.771.1644859246347;
Mon, 14 Feb 2022 09:20:46 -0800 (PST)
X-Received: by 2002:a05:620a:10b3:: with SMTP id h19mr416023qkk.644.1644859246129;
Mon, 14 Feb 2022 09:20:46 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!2.us.feeder.erje.net!feeder.erje.net!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, 14 Feb 2022 09:20:45 -0800 (PST)
In-Reply-To: <cee3f619-3b3f-4fe7-9351-a967ae36863dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.94.110.221; posting-account=bfqVhAoAAABnxNiPDFL3mSrvM7YNO32Q
NNTP-Posting-Host: 87.94.110.221
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<db19b4f0-75a2-4b93-8d67-b72e1f072b67n@googlegroups.com> <cee3f619-3b3f-4fe7-9351-a967ae36863dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <403b90d3-6893-4470-8147-4b7cfacad9c1n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: oh2...@gmail.com (Mike)
Injection-Date: Mon, 14 Feb 2022 17:20:46 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 65
 by: Mike - Mon, 14 Feb 2022 17:20 UTC

On Monday, February 14, 2022 at 6:49:59 PM UTC+2, gnuarm.del...@gmail.com wrote:
> On Monday, February 14, 2022 at 11:34:42 AM UTC-5, Mike wrote:
> > On Sunday, February 13, 2022 at 1:12:45 PM UTC+2, mpetre...@gmail.com wrote:
> > > I'm using ESP32Forth v v7.0.6.14
> > > I have a (BIG) problem with FOR NEXT loop....
> > > A simple example:
> > > : myLoop
> > > 5 for r@ . next ;
> > > display 5 4 3 2 1 0
> > > So, 6 iterations !!!
> > > And not 5 iterations as attempted....
> > > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> > > BR
> > In hardware the simplest FOR NEXT implementation iterates at least one time.
> What do you mean by this? A FOR NEXT loop is not exactly hardware. The hardware needs a counter that is decremented and the terminating condition is either reaching zero (internal =0 flag) or counting past zero (underflow or negative flag depending on data type). Depending on how you implement the details of the index numbers this can be at the beginning of the loop or the end. Put it at the beginning of the loop and you get N iterations including none for a starting count of zero. Put it at the end of the loop and you get N+1 iterations from N down to 0.
>
> In all cases of the loop structure the number of iterations can be modified by jumping into the loop appropriately.
>
> This all seems pretty simple and hardware independent to me. What are you thinking?

There are some hardware looping implementations in native Forth processors and for example in PIC24/33.
Those typically execute the body of the loop once before decrementing and checking the index at the end of the loop.

> > But I wanted FlashForth to execute the loop as many times as requested,
> > and skip the loop if zero times is requested.
> > This is well aligned with my normal use cases in FlashForth and avoids
> > extra tests or adjustments before the loop. The index going from n-1 to 0
> > is well suited for indexing into a zero based array which is what I use a lot,
> > for example for running averages.
> > FOR is implemented so that it starts with jumping to NEXT to check if the index is zero,
> > if not zero NEXT jumps back to FOR (after the inital jump instruction).
> You mean check without decrementing? Does you loop exit when the index reaches zero or when zero is decremented below zero?

That was a simplification. Actually it decrements and checks if it is decremented below zero.

> So if you are indexing a zero based array, how do you write code to handle 0 to N iterations?

I let FOR NEXT count the iterations and use TOS, or a variable, or a pointer for the indexing.
Flashforth has a reentrant pointer register with indirect addressing (P@ P! etc.)

-- Mike

Re: ESP32Forth big bug with FOR..NEXT loop ...???

<59809d79-6331-433e-b9da-d15a3940c238n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:9e4f:: with SMTP id h76mr28009qke.645.1644864784350;
Mon, 14 Feb 2022 10:53:04 -0800 (PST)
X-Received: by 2002:a05:620a:94e:: with SMTP id w14mr133814qkw.485.1644864784143;
Mon, 14 Feb 2022 10:53:04 -0800 (PST)
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, 14 Feb 2022 10:53:03 -0800 (PST)
In-Reply-To: <403b90d3-6893-4470-8147-4b7cfacad9c1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <db2b31b3-f510-408b-beb1-a591d3132299n@googlegroups.com>
<db19b4f0-75a2-4b93-8d67-b72e1f072b67n@googlegroups.com> <cee3f619-3b3f-4fe7-9351-a967ae36863dn@googlegroups.com>
<403b90d3-6893-4470-8147-4b7cfacad9c1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <59809d79-6331-433e-b9da-d15a3940c238n@googlegroups.com>
Subject: Re: ESP32Forth big bug with FOR..NEXT loop ...???
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Mon, 14 Feb 2022 18:53:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 96
 by: Rick C - Mon, 14 Feb 2022 18:53 UTC

On Monday, February 14, 2022 at 12:20:47 PM UTC-5, Mike wrote:
> On Monday, February 14, 2022 at 6:49:59 PM UTC+2, gnuarm.del...@gmail.com wrote:
> > On Monday, February 14, 2022 at 11:34:42 AM UTC-5, Mike wrote:
> > > On Sunday, February 13, 2022 at 1:12:45 PM UTC+2, mpetre...@gmail.com wrote:
> > > > I'm using ESP32Forth v v7.0.6.14
> > > > I have a (BIG) problem with FOR NEXT loop....
> > > > A simple example:
> > > > : myLoop
> > > > 5 for r@ . next ;
> > > > display 5 4 3 2 1 0
> > > > So, 6 iterations !!!
> > > > And not 5 iterations as attempted....
> > > > Other FORTH versions (FlashForth, gForth) with FOR..NEXT make only 5 iterations
> > > > BR
> > > In hardware the simplest FOR NEXT implementation iterates at least one time.
> > What do you mean by this? A FOR NEXT loop is not exactly hardware. The hardware needs a counter that is decremented and the terminating condition is either reaching zero (internal =0 flag) or counting past zero (underflow or negative flag depending on data type). Depending on how you implement the details of the index numbers this can be at the beginning of the loop or the end. Put it at the beginning of the loop and you get N iterations including none for a starting count of zero. Put it at the end of the loop and you get N+1 iterations from N down to 0.
> >
> > In all cases of the loop structure the number of iterations can be modified by jumping into the loop appropriately.
> >
> > This all seems pretty simple and hardware independent to me. What are you thinking?
> There are some hardware looping implementations in native Forth processors and for example in PIC24/33.
> Those typically execute the body of the loop once before decrementing and checking the index at the end of the loop.
> > > But I wanted FlashForth to execute the loop as many times as requested,
> > > and skip the loop if zero times is requested.
> > > This is well aligned with my normal use cases in FlashForth and avoids
> > > extra tests or adjustments before the loop. The index going from n-1 to 0
> > > is well suited for indexing into a zero based array which is what I use a lot,
> > > for example for running averages.
> > > FOR is implemented so that it starts with jumping to NEXT to check if the index is zero,
> > > if not zero NEXT jumps back to FOR (after the inital jump instruction).
> > You mean check without decrementing? Does you loop exit when the index reaches zero or when zero is decremented below zero?
> That was a simplification. Actually it decrements and checks if it is decremented below zero.
> > So if you are indexing a zero based array, how do you write code to handle 0 to N iterations?
> I let FOR NEXT count the iterations and use TOS, or a variable, or a pointer for the indexing.
> Flashforth has a reentrant pointer register with indirect addressing (P@ P! etc.)

If you only want the FOR NEXT construct to count iterations and not provide an index to facilitate various addressing operations (which are mostly zero based, it is a computer after all), then why perform the xtra jump? As you say, the decrement and jump operation is typically one instruction. Jumps can muddy execution optimizations. Do an initial test prior to starting the loop. Heck, that can even be done prior to the FOR NEXT construct leaving the loop to be general purpose.

But to each his own.

I've never added registers outside the Forth virtual machine other than a CPU status register. I use flags for conditionals and optimize the code for a simple CPU. This results in 1 clock cycle per instruction for everything and provides for essentially 1 clock cycle interrupt response (or is it zero clock cycles?). When an interrupt is asserted the next instruction is a subroutine call to the interrupt handler that pushes the return address on the return stack and the processor status word on the data stack. The next instruction is the first instruction in the interrupt handler. The FPGA block RAM is large enough there are 8 stacks implemented, one for the main process and 7 interrupts.

The instructions for FOR/NEXT DO/LOOP loops use the return stack for the operands which can also serve as an address. The tools can adjust the index and limit to align with the array pointer and serve dual purposes. Memory instructions in my CPU use the return stack for the memory address completing the utility.

I like lean, simple architectures that are easy to use.

--

Rick C.

++ Get 1,000 miles of free Supercharging
++ Tesla referral code - https://ts.la/richard11209

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor