Re: need ideas re loops
Samuel Tardieu <[email protected]> 14 Nov 2004 11:30:24 +0100
| Newsgroups | gmane.comp.lang.forth.picforth |
|---|---|
| Organization | RFC 1149 (see http://www.rfc1149.net/) |
| Message-ID | <[email protected]> |
>>>>> "David" == David McNab <[email protected]> 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 -- [email protected] -- http://www.rfc1149.net/sam