Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday April 24, 2008
09:43 AM

Devel::Deprecate - Automatically Schedule Deprecations

[ #36239 ]

Devel::Deprecate has just been uploaded to PAUSE. Basic usage:

use Devel::Deprecate 'deprecate';

sub name {
    my ( $self ) = @_;

        reason => 'Please use the set_name() method for setting names',
        warn   => '2008-11-01',    # also accepts DateTime objects
        die    => '2009-01-01',    # two month deprecation period
        if     => sub { return @_ > 1 },
    if ( @_ > 1 ) {
        $self->{name} = $_[1];
        return $self;
    return $self->{name};

Note that the deprecate function is designed to be a no-op unless you're running tests.

I also have to confess that though there's a touch of cruft, I'm particularly pleased with how the test suite came out on that.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I'd actually really like "version-based deprecation", so that I can ship a CPAN module which cleanly bitches at developers that they're using an API which will be removed in a future numbered version.
    • I should also mention: Nice. This is quite slick and makes me very happy :)
      • Thank you. I'm quite happy with it myself :) I just hope it turns out to be as useful as it seems.

    • Can you show me the syntax you'd like to see for that? I think there's enough flexibility in it now, so I must be misunderstanding you.