On Sun, Jan 20, 2002 at 07:25:17PM -0500, Damian Conway wrote:
> > How would you use an $x lexically scoped to the loop block?
> 
> You can't...directly. Nor can a C<while> or C<if>. The new rule is that
> to be lexical to a block it has to be declared in the block, or in the
> block's parameter list.
> 
> You'd need to use another layer of braces:
> 
>       do {
>       loop my $x=0; $x < 100; $x++ {
>           ...
>       }
>       }

Hmmm.  I understand the desire for lexical simplicity and all, but
this seems like a Great Leap Backwards to 5.003.

    {
        my $foo;
        foreach $foo (@bar) {
            ...
        }
    }

The C<foreach @bar -> $foo> is a good out for the common case, and
I'll give that more complicated for loops will be uncommon enough so
having a few block wrappers won't matter.  But I'm worried about how
will we replicate the current behavior of the common idiom:

    while( my $line = <FILE> ) {
        ...
    }

Will it be:

    while <FILE> -> $line {
        ...
    }

or do we have to start wrapping things up?

And then there's this one:

    if( my $foo = bar() ) {
        ...
    }

how would that be written?


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
It wasn't false, just differently truthful.
        -- Abhijit Menon-Sen in <[EMAIL PROTECTED]>

Reply via email to