Re: FOR...NEXT

Anton Ertl <anton-8NJIiSa5LzB3ZGU3T6kWFyEcasqEdqbRs2V0tQ3P5b8@public.gmane.org>
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <[email protected]>
On Sat, Feb 23, 2019 at 03:38:45PM +0000, dch wrote:
> Why does FOR run n+1 times? It seems inane. `4 FOR ... NEXT` should not 
> run 5 times, that's absolutely ridiculous. Even Chuck's FOR loops ran n 
> times in Forth and n times in ColorForth. So there must be a good reason 
> for this.

Different Forths behave differently for FOR...NEXT:

gforth: n+1 iterations
iforth: n+1 iterations
bigforth: n+1 iterations
SwiftForth: for ?
VFX: for ?
lxf: n iterations

Because of that, I think that SwiftForth and VFX have the best
behaviour.  However, I guess that Gforth has inherited its FOR..NEXT
behaviour from bigForth.

- anton
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.