develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24250] "return" required in some anonymous closures

Elizabeth Mattijsen
October 20, 2003 03:18
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
(I should stop answering my own posts  ;-)

At 11:55 +0200 10/20/03, Elizabeth Mattijsen wrote:
>Hmmm... both of the following return correct results also:

The problem can be simplified to the following code:

my $foo = 'foo';
my $get = sub () {$foo};
my $set = sub ($) {$foo = $_[0]};
print "foo = $foo = ".$get->()."\n";
foo = bar = foo

so this looks like an optimizer problem to me: the $get sub is 
referring to something else than the package lexical $foo.

Liz Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About