Aaron Sherman wrote:

> Of course it brings other less wholesome things to mind like "elsfor"
> and "elsloop" and "if ... elsfor" and "for ... elsif ... elsloop ...
> else", but why not?

Because Perl 6 is already...err...over-endowed with keywords, few of which are
as klunky as these would be. If we were to generalize to cascaded loops I'm
pretty sure we'd have to consider "else if", "else while", "else for" etc. instead.


> > But the aliased value, $_, is restricted to the scope of the C<while>'s
> > block, it isn't going to be accessible in the block associated with the
> > C<else> (you would be getting some $_ from an outer scope).
> 
> You're thinking of loops in a curious and convoluted way,

Err. No she's not. Allison is right on the money. She's thinking of
loops in the Perl 6 way (which is less curious and convoluted).


> Try this out:
> 
>     { loop-keyword [ conditional/declaration ]
>         block
>         { else-clauses ...} }
> 
> The loop itself comprises an outer scope in which the conditionals or
> declarations exist. Then, each block comprises a sub-scope. In this way,
> there is no confusion, no special case, no violation of the rules.

Except the rule that there are no implicit scopes (except file scope).


> It becomes reasonable now to have:
> 
>         for @a -> $b {
>                 stuff using $b
>         } elsfor @c -> $d {
>                 more stuff using $b and $d
>         } else {
>                 yet further stuff with access to $b and $d
>         }

Except that, as Allison subsequently correctly pointed out, the aliasing arrow
doesn't work that way at all.

Damian

Reply via email to