develooper Front page | perl.perl5.porters | Postings from February 2009

Re: deprecating Switch.pm

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
February 25, 2009 09:07
Subject:
Re: deprecating Switch.pm
Message ID:
20090225170702.GL81285@plum.flirble.org
On Mon, Feb 23, 2009 at 10:11:56PM +0100, Steffen Mueller wrote:
> Hi Nicholas,
> 
> Nicholas Clark wrote:
> >     Add deprecate.pm. Deprecate shipping Switch.pm in the core distribution.
> 
> Yay!
> 
> > 3: Fix the bit of the code that is commented as "fragile"
> 
> What's wrong with the following change that fixes 1/2 of the fragility?
> 
> Make the ugly line
> 
> use if $] >= 5.011, 'deprecate';
> 
> become the ugly line
> 
> BEGIN { if ($] >= 5.11) { require deprecate; deprecate->import(); } }
> 
> which does the same without additional call stacks. And reads more
> easily (to me), too.

Well, basically, I didn't think of writing it on one line. :-)
I was thinking

use deprecated if $] >= 5.11;

then "oh crap, that seems to be a syntax error" and then thought that writing
it all out longhand would be a big intrusion on the code of each module we
want to deprecate.

However, I'm coming round to the view that your one liner is possibly better
than if.pm, despite if.pm existing for just this.

Nicholas Clark

Thread Previous | Thread Next


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