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

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

Elizabeth Mattijsen
October 20, 2003 05:29
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About