So, after all our discussions, my thinking regarding alternate blocks for
loops is now running like this:

    1. It would definitely be useful to be able to catch the failure of a 
       block to iterate.

    2. This ability should be available for all three types of block: C<while>,
       C<for>, and C<loop>.

    3. The "obvious" syntax:

            while condition() {
                ...
            }
            else {
                ...
            }
            
       is fraught with difficulty because C<else> is already so closely
       bound to C<if> in the community consciousness.
       
    4. Using C<else> also encourages the expectation of C<elsif>, C<elswhile>,
       C<elsunless>, C<elsinore>, etc. But I don't believe the language can
       comfortably bear the weight of such expectations. Or such keywords.
       
    5. My preferred option would be to restrict the "alternative block" to
       only being a simple block (i.e. no cascading), and to introduce it
       with some other keyword.
       
    6. C<otherwise> would seem to fit the bill rather nicely.
    

So, I guess if Larry were to ask my opinion, I'd suggest that we allow:

    while condition() {
        ...
    }
    otherwise {
        ...
    }
    
and:

    for @list -> $next {
        ...
    }
    otherwise {
        ...
    }
    
and:

    loop ($i=0; i<$max; i+=2) {
        ...
    }
    otherwise {
        ...
    }

I now confidently await Larry's coming up with an entirely different solution ;-)

Damian

Reply via email to