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 06:15
Subject:
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
20031020131517.2513.21@llama.elixent.com
Mark Jason Dominus <mjd@plover.com> writes:
>Dave Mitchell <davem@fdgroup.com>:
>> 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. 
>
>Oh well, so much for the principle of least astonishment.
>
>What's the workaround for this feature?

A. Don't give the () prototype (they don't do anything useful
   on dynamic calls anyway).
B. Add a return 




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