home .. forth .. colorforth mail list archive ..

Re: [colorforth] Dare I say ANS!


Hi Samuel,

Thanks for the explanation. I was so rooted in the DO ... LOOP version of i
that I missed the obvious.
Since the FOR ... NEXT loop only stores the down-count, there is no
information available about where the loop started.
Therefore i cannot return 0 ... n .

What I find fascinating is the fact that I now see just how clever DO ...
LOOP is. By storing both the start count and up-count on the R-stack, you
can test for termination by the two values being equal, and make i return 0
.... n .

What is even more fascinating is that colorForth no longer requires DO ...
LOOP, as the A register allows an effective up-count.
You can also keep an "up-count" on the parameter stack by adding 1+ DUP in
the loop.

My conclusion is that i should not exist in colorForth.
It can easily be replaced by 1- DUP on the parameter stack, if you really
want a down-count.

Can a Forth standard be useful simply by prohibiting certain words?

Regards

Howerd


---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com