Devel::Deprecate - Automatically Schedule Deprecations

Ovid on 2008-04-24T14:43:51

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

use Devel::Deprecate 'deprecate';

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

    deprecate(
        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.


Feature request!

jesse on 2008-04-24T18:27:03

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.

Re:Feature request!

jesse on 2008-04-24T18:27:34

I should also mention: Nice. This is quite slick and makes me very happy :)

Re:Feature request!

Ovid on 2008-04-24T22:06:51

Thank you. I'm quite happy with it myself :) I just hope it turns out to be as useful as it seems.

Re:Feature request!

Ovid on 2008-04-24T22:05:48

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.