On Fri, 2002-04-26 at 19:30, Miko O'Sullivan 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?
> 
> Weeeeellllll, I agree with the concept, but boyoboy those names ain't gonna
> fly.  We'll have to head down the road of
> 
>    unlessfor

Why? We don't have an "unlessif", why would we ever have "unlessfor"?!

>    elseuntil

I would expect that to be "elsuntil", but as we're dropping "until" from
the language, it's a moot point.

>    unlessuntil

See above.

> Two issues spring to mind:
> 
> 1) Do we have a reality check on why this syntax is needed?  I agree it's
> cool idea, but can anyone name a real-world scenario where it would be
> useful?  Can we do things just bcause they're cool?  That approach didn't
> work too well for me as a teenager, but then nothing else did either.

It's not because it's cool. It's because the alternative is:

Perl5:
        $did = 0;
        for($i=0;$i<$max;$i++) {
                ...
        }
        unless ($did) {
                foreach (@x) {
                        ...
                }
        }

Perl6:

        loop $i=0;$i<$max;$i++ {
                ...
                ELSE {
                        for @x -> $_ {
                                ...
                        }
                }
        }

Proposed Perl6:

        loop $i=0;$i<$max;$i++ {
                ...
        } elsfor @x -> $_ {
                ...
        }

Points for last option:

1. Cleaner code

2. Scope is cleaner. Why does the "we never executed this block" code,
have to exist inside of the block's scope? What are we preserving?

At the very least, moving the else out of the block makes sense, but I
think preserving elsif is useful as well. The fact that that calls for
the possibility of elsfor, elseloop, etc, is IMHO just a nice extra.


Reply via email to