develooper Front page | perl.perl5.porters | Postings from August 2005

[perl #7615] (if|unless) ( local ... ) not undone

From:
Mike Guy
Date:
August 26, 2005 09:46
Subject:
[perl #7615] (if|unless) ( local ... ) not undone
Message ID:
E1E8hLo-0006MU-J2@draco.cus.cam.ac.uk
Steve Peters wrote
> This behavior has been fixed in bleadperl by not allowing it.  
> 
> > ./perl rt_7615.pl
> Can't localize lexical variable $a at rt_7615.pl line 4.

No it hasn't.    I suspect you did the wrong test  -  what's that
"lexical" doing in the error message?

When I try

perl5.8.6 -w
$a = 10;
if (local $a = 1){
}
print $a; # Should be 10, not 1
__END__
Found = in conditional, should be == at - line 2.
1

the bug is still present.

I presume this is another manifestation of the fact that a conditional
involves *two* scopes, one including the condition and one not.
Perl conflates them, with unfortunate results.

I presume the resaon for conflating them is efficiency.


Mike Guy



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About