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

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

From:
Nick Ing-Simmons
Date:
October 20, 2003 05:34
Subject:
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
20031020123403.2513.16@llama.elixent.com
Elizabeth Mattijsen <liz@dijkmat.nl> writes:
>(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]};
>$set->('bar');
>print "foo = $foo = ".$get->()."\n";
>__END__
>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.

What is a 'package lexical' ?
  - things are either in package or lexical never both...




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