develooper Front page | perl.perl5.porters | Postings from April 2012

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

April 21, 2012 01:48
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
On Friday, 20 April 2012, Dave Mitchell wrote:

> On Fri, Apr 20, 2012 at 12:37:55PM +0100, Nicholas Clark wrote:
> So, I think we should remove this 'feature'.
> If anyone is using it as intended, then the worst they'll get is
> a performance decrease, with a const sub downgraded to a real sub that
> returns the expected value. Perhaps we could issue a warning, with
> perldiag.pod explaining what to do if you really wanted a const sub, and
> to stick a 'return' in to defeat the warning if you didn't want it.

We use this a lot at work. We can recode to use other mechanisms to produce
constants, tho, so it's not a big deal, but my suspicion is its widely
used. Keep in mind that constants can be used to modify the optree and are
used for that as much as a value.

Dosomething() if CONSTANT;

Is used a lot.


perl -Mre=debug -e "/just|another|perl|hacker/" Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About