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

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

From:
Elizabeth Mattijsen
Date:
October 20, 2003 05:29
Subject:
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
p05111b03bbb984e2a06b@[192.168.56.2]
At 11:45 +0100 10/20/03, Dave Mitchell wrote:
>On Mon, Oct 20, 2003 at 12:17:24PM +0200, Elizabeth Mattijsen wrote:
>>  (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:
>  > so this looks like an optimizer problem to me: the $get sub is
>  > referring to something else than the package lexical $foo.
>This isn't a bug, it's a feature :-)
>sub () {$lexical} is a constant sub generator, ie each call to 'sub'
>returns a new constant sub rather than a closure. It doesn't seem to be
>well documented though. Been around since 5.8.0.

I always thought you would need to document a bug before it becomes a 
feature?  ;-)


Seriously, I haven't been able to find _any_ documentation on this 
feature.  It definitely is not mentioned in the 5.8.0 perldelta (or 
it is described without the terms "constant" or "generator").

If this _is_ a new feature of 5.8.0, maybe it should be at least 
documented in the 5.8.2 perldelta?  And possible somewhere else. 
Suggestions for locations where this should be documented?  I'll 
write up a description and submit a patch then.


Liz



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