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

Re: Perl 5.10.1

Thread Previous | Thread Next
Marvin Humphrey
July 1, 2009 17:44
Re: Perl 5.10.1
Message ID:
On Wed, Jul 01, 2009 at 06:10:42AM -0400, John Peacock wrote:

> Ahem...
> package LimitTest;
> use version::Limit;
> use version;
> our $VERSION = version->new("3.2.5");
> version::Limit::Scope(
>     "[0.0.0,1.0.0)" => "constructor syntax has changed",
>     "[2.2.4,2.3.1)" => "frobniz method croaks without second argument",
> );
> 1;


I like the way that fine grained control is the responsibility of the module
author under the version::Limit model, while the user is only responsible for
requesting an interface in the form of a package name and a version number.

Contrast that with Ingy's "only" module, where the user must specify the range
of acceptable versions, and which encumbers 'use' directives with non-standard

  use only LimitTest => '0.0.0-0.1.0';

I also like the way that version::Limit allows authors to turn what would
ordinarily be a runtime error into a compile-time error.  Maybe that's a
little heavy-handed for minor compat breaks, but Jan might consider that a
feature, as it would discourage such breaks. ;)

So, while version::Limit isn't a panacea, it's useful already.  :)

> The only caveat is that your consumers MUST include a version number on the
> 'use' line, but I just thought of a way to enforce that; expect a new
> release to CPAN of version::Limit real soon now...

Hmm, I'm not sure I'd always take advantage of that.  Would this "use base"
directive fail because it omits the version number?

  use LimitTest 3;
  use base qw( LimitTest );

> > This assumption is made in many places, like the META.yml files,
> > PREREQ_PM in Makefile.PL, or in the CPAN shell when asked to upgrade
> > modules.
> These issues, on the other hand, are outside of my direct control, which is one
> reason I haven't made a bigger push to get version::Limit out there and known...

Well, I'm grateful that you've solved a hard problem so elegantly.  

I actually prefer your model to the one described in the Perl 6 versioning
spec at <>.

Under version::Limit, users can just say... 

  use Dog 1.2.1;

... and the author of Dog gets to decide wheather the request for the
interface defined by "Dog 1.2.1" is still compatible with the installed

That option doesn't seem to be available under Synopsis 11, if I'm reading it

    Saying C<1.2.1> specifies an I<exact> match on that part of the
    version number, not a minimum match.  To match more than one version,
    put a range operator as a selector in parens:

    use Dog:ver(v1.2.1..v1.2.3);
    use Dog:ver(v1.2.1..^v1.3);
    use Dog:ver(v1.2.1..*);

As with, the user gets very fine control over what versions are deemed
acceptable, but there doesn't seem to be a way to express "Give me any version
of this module that implements the interface defined by 'Dog 1.2.1'".

Marvin Humphrey

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About