On 2008-Dec-16, at 6:21 pm, Timothy S. Nelson wrote:
Or, instead of having a new block, just add the iterator indicator to the NEXT block, and get rid of ENTER and LEAVE. That way, you'd have this sequence:
-       FIRST {}
-       NEXT 0 {} # Replaces ENTER
-       NEXT 1..* {} # Does NOTFIRST
-       NEXT * {} # Replaces LEAVE
-       LAST {}

        Would that do it?

Not quite -- the idea is that you could put the LOOP block anywhere in the body of the loop, and it would execute at that point. NEXT and friends always occur at the end (or beginning) of their block.

Nor would it work to take an existing block like NEXT and allow it to be positioned in the middle of the body, because it wouldn't be possible to duplicate what they already do -- in this example, the NEXT wouldn't get executed when "next if something()" occurs:

                next if something();
                NEXT { ... }

On Tue, 16 Dec 2008, Jon Lang wrote:
How do you compute '*'?  That is, how do you know how many more
iterations you have to go before you're done?

In some cases, it won't have to be computed, in some cases it won't be computeable (which should be an error). I'd say it'd be fair enough to say that 1..(*-1) should be an error in non-bounded(?) loops (ie. while).

That sounds right to me. Does 'for @foo' take a snapshot of @foo, or can you change the bounds by changing @foo while the loop is running? In which case trying to count back from * might be an error for anything except constant bounds.


Reply via email to