[PicForth] Re: need ideas re loops
Samuel Tardieu
sam at rfc1149.net
Sun Nov 14 11:30:24 CET 2004
>>>>> "David" == David McNab <david at rebirthing.co.nz> writes:
David> As a python and C programmer, I've been totally spoilt by
David> 'break' and 'continue', which don't seem to be available in
David> PicForth.
You can emulate "break" easily by using "0 while" in a
begin/while/repeat loop (as there may be several "while" in it).
Note that although I am not sure it is portable Forth, you can also
use "0 while" in a begin/until loop ("until" is implemented as "0
while repeat", so in PicForth this is indeed a begin/while/repeat
loop).
Emulating "break" in a begin/again loop is as easy as making it a
begin/while/repeat loop.
I am reluctant to add a "break" word that would do "0 while" as this
word is likely to be found in programs for embedded targets.
Emulating "continue" can be done as easily: (untested)
: continue dup l-goto unreachable ;
Sam
--
Samuel Tardieu -- sam at rfc1149.net -- http://www.rfc1149.net/sam
More information about the PicForth
mailing list