Closed ghost closed 7 years ago
This is normal in classical Forth.
https://forth-standard.org/standard/core/UNLOOP
"Discard the loop-control parameters for the current nesting level. An UNLOOP is required for each nesting level before the definition may be EXITed"
I'll update the readme because do loop must be understood internally otherwise it is very easy to mess things up (there are other constructs that don't work well with do loops).
I was trying to use unloop exit as the equivalent of leave which I had in my original code. Is there some reason you didn't implement leave ?
On Fri, Dec 30, 2016 at 3:12 AM, Attila Magyar notifications@github.com wrote:
This is normal in classical Forth.
https://forth-standard.org/standard/core/UNLOOP
"Discard the loop-control parameters for the current nesting level. An UNLOOP is required for each nesting level before the definition may be EXITed"
I'll update the readme because do loop must be understood internally otherwise it is very easy to mess things up (there are other constructs that don't work well with do loops).
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zeroflag/punyforth/issues/8#issuecomment-269754484, or mute the thread https://github.com/notifications/unsubscribe-auth/AEM6-PsEEbh5RGUYXeHwESBRmE9eBkU5ks5rNNkVgaJpZM4LX7v3 .
-- Craig Lindley / Heather Hubbard
495's Recordings: craigandheather.net/495spage.html New Recordings: craigandheather.net/cnmpage.html Latest rock CD: craigandheather.net/oneinarow.html Latest non-rock CD: craigandheather.net/craigdoesfingerstyle.html
Personal Website: craigandheather.net
Phone: (719) 495-1873 Cell: (719) 502-7925
If you’re one in a million, there are now seven thousand people exactly like you.
I haven't needed it yet. I like factoring out the logic in a new word and use exit to exit from the word instead of just the loop.
I updated the readme with some notes on using unloop and exit from nested loops.
Unless I'm missing something it seems like there is a bug in unloop when used in nested do loops. The code below illustrates the problem.
: test 20 0 do i . cr 10 0 do i . i 4 = if unloop exit then loop loop ;