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

deprecating Switch.pm

Thread Next
From:
Nicholas Clark
Date:
February 23, 2009 02:46
Subject:
deprecating Switch.pm
Message ID:
20090223104629.GZ81285@plum.flirble.org
I did this:

commit e76b2c0c0a5a6bcf7f940f55f050b6f3cecac437
Author: Nicholas Clark <nick@ccl4.org>
Date:   Mon Feb 23 11:27:08 2009 +0100

    Add deprecate.pm. Deprecate shipping Switch.pm in the core distribution.


Switch changes like this:

diff --git a/lib/Switch.pm b/lib/Switch.pm
index 709442e..8e98d29 100644
--- a/lib/Switch.pm
+++ b/lib/Switch.pm
@@ -4,8 +4,10 @@ use strict;
 use vars qw($VERSION);
 use Carp;
 
-$VERSION = '2.14';
+use if $] >= 5.011, 'deprecate';
 
+$VERSION = '2.14_01';
+  
 
 # LOAD FILTERING MODULE...
 use Filter::Util::Call;


[Oops. Bonus blank line]. Anyway, it now behaves like this:

$ /Users/nick/Sandpit/511v/bin/perl5.11.0 -we 'use Switch; print $INC{"Switch.pm"}'
Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at -e line 1
$ 
$ /Users/nick/Sandpit/511v/bin/perl5.11.0 -wle 'use Switch; print $INC{"Switch.pm"}'
Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at -e line 1
/Users/nick/Sandpit/511v/lib/perl5/5.11.0/Switch.pm
$
$ # "Install" it from CPAN:
$
$ cp /Users/nick/Sandpit/511v/lib/perl5/5.11.0/Switch.pm /Users/nick/Sandpit/511v/lib/perl5/site_perl/5.11.0/Switch.pm
$
$ /Users/nick/Sandpit/511v/bin/perl5.11.0 -wle 'use Switch; print $INC{"Switch.pm"}'
/Users/nick/Sandpit/511v/lib/perl5/site_perl/5.11.0/Switch.pm
$
$ # And demonstrate undoing that:
$
$ rm /Users/nick/Sandpit/511v/lib/perl5/site_perl/5.11.0/Switch.pm
override r--r--r--  nick/staff for /Users/nick/Sandpit/511v/lib/perl5/site_perl/5.11.0/Switch.pm? y
$
$ /Users/nick/Sandpit/511v/bin/perl5.11.0 -wle 'use Switch; print $INC{"Switch.pm"}'
Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at -e line 1
/Users/nick/Sandpit/511v/lib/perl5/5.11.0/Switch.pm

So, if you load the file from the core library path, it warns.
If you have installed the *identical* file from CPAN, it does not.

This keeps Andreas happy, because CPAN won't contain two files in different
distributions that differ, but claim to be the same version of the same
package.

Implementation of deprecate.pm is a bit minimal currently:

http://perl5.git.perl.org/perl.git/blob/HEAD:/lib/deprecate.pm


And I've not worked out how to patch CPAN.pm and CPANPLUS.pm to know about
deprecate and hence change from this:

cpan[1]> install Switch
CPAN: Storable loaded ok (v2.19)
Going to read '/Users/nick/.cpan/Metadata'
  Database was generated on Mon, 23 Feb 2009 08:29:00 GMT
Switch is up to date (2.14_01).

cpan[2]> 

to behaving like a "force install".

[But Andreas and Jos agreed to the plan in the queue for the buffet at the
social event at YAPC::EU 2008, so there's no wiggling out of it now. :-)]


Anyway, help wanted. Does anyone want to do any of:

1: Write tests
2: Write documentation
3: Fix the bit of the code that is commented as "fragile"
4: Write a better warning message
5: Decide whether the core is allowed to issue multi-line diagnostic messages
6: Propose a patch for CPAN.pm
7: Propose a patch for CPANPLUS.pm
8: Comment further on the @INC order thread

Nicholas Clark

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