> Ok, now I understand the plan.  In brief, in the following example $result
> is scoped to the block that encloses the whole loop:
> 
>    while (my $res = $search->getnext) { ...}

Yes. Because it's a lexical variable declared outside the closure controlled
by the C<while>.


> However, in the next example, $res is scoped to the loop:
> 
>    while $search->getnext() -> $res { ...}

Yes. Because it's a parameter of the closure controlled by the C<while>.


> Right?  OK, that sounds cool.  We still have loop-scoped variables.  I'd
> like to suggest, though, that the first example would refuse to compile.

I don't think so.


> If the plan is to significantly change the behavior of something as popular as
> that construct (and I did some research, it's VERY popular, details
> available on request), it would make more sense to refuse to compile than to
> DWIDM (Do What I Don't Mean).

Hmmmm. By the same argument we should refuse to compile the very popular 
C<$var[$idx]> and C<$var{key}> constructs, since they no longer mean what
they meant in Perl 5.

I don't think that's the right answer. A construct like:

        while (my $res = $search->getnext) { ...}

has a valid meaning in Perl 6. In fact, it's meaning in Perl 6 is far more
reasonable than in Perl 5.

However, Miko has highlighted a genuine transition problem, and one might imagine
something like:

        use warnings 'P52P6';

that would point out potential problems like this.


Damian

Reply via email to