,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2016-05-16 21:55:15 AtH wrote: | testcase - Another use of UNLOOP | see: https://forth-standard.org/standard/core/UNLOOP#contribution-18 `------------------------------------------ Old standard concentrates on UNLOOP EXIT I suggest to legalize in the new standard UNLOOP LEAVE for breaking the outer loop. ,---------. | Replies | `---------´ ,------------------------------------------ | 2016-05-17 07:39:42 AntonErtl replies: | testcase - Another use of UNLOOP | see: https://forth-standard.org/standard/core/UNLOOP#reply-19 `------------------------------------------ A common implementation of UNLOOP is as just a run-time word, while a common implementation of LEAVE is a compile word that generates a branch to the end of the loop. Your suggestion would cause quite a bit of additional implementation complexity with such a LEAVE. If we need to leave two DO LOOPs, a word LEAVE2 would be simpler to implement (although word counters won't like it). Or, with the current standard, put the nested loop in an extra colon definition, and leave it with UNLOOP UNLOOP EXIT. ,------------------------------------------ | 2016-05-17 12:39:26 AtH replies: | testcase - Another use of UNLOOP | see: https://forth-standard.org/standard/core/UNLOOP#reply-20 `------------------------------------------ There are two ways to implement LEAVE 1. As you said, compile UNLOOP with direct BRANCH to the first word after first LOOP 2. When end of loop address is part of discarded loop-control parameters, fetch this exit point and indirect branch to it. First implementation is slightly faster, the second allows to use UNLOOPs for leaving any number of nested loops. I use the second way, LEAVE is just a regular primitive without IMMEDIATE and DO always knows, where it's LOOP UNLOOP could be more powerful, without extra words in the standard like LEAVE2 LEAVE3 etc.