Digest #8 2016-05-18


[18] 2016-05-16 21:55:15 AtH wrote:

testcase - Another use of UNLOOP

Old standard concentrates on UNLOOP EXIT

I suggest to legalize in the new standard UNLOOP LEAVE for breaking the outer loop.


[r19] 2016-05-17 07:39:42 AntonErtl replies:

testcase - Another use of UNLOOP

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.

[r20] 2016-05-17 12:39:26 AtH replies:

testcase - Another use of UNLOOP

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.