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

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

From:
demerphq
Date:
April 21, 2012 01:48
Subject:
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
CANgJU+W9KYu+--qsp=kcNvyAby61dgTUOe6b9h_80vTipKY_jQ@mail.gmail.com
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.

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"



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