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

Re: Perl 5.10.1

Thread Previous | Thread Next
From:
John Peacock
Date:
July 1, 2009 03:10
Subject:
Re: Perl 5.10.1
Message ID:
4A4B3622.8000604@havurah-software.org
Jan Dubois wrote:
> It is not just the local installation, it is also the language itself
> that has the assumption about immutable interfaces built in:
> 
>     use MyModule 2.3;
> 
> This means that version 2.3 or *any* later version of the module will be
> fine.  There is no way to tell that MyModule 3 is not acceptable.

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;

...later...

$ perl -e 'use LimitTest 0.0.1; print "OK!\n"''
Cannot 'use LimitTest v0.0.1': constructor syntax has changed
(v0.0.0 <= v0.0.1 and v0.0.1 < v1.0.0) at lib/version/Limit.pm line 57.
BEGIN failed--compilation aborted at -e line 1.

$ perl -e 'use LimitTest 2.3.0; print "OK!\n"''
Cannot 'use LimitTest v2.3.0': frobniz method croaks without second argument
(v2.2.4 <= v2.3.0 and v2.3.0 < v2.3.1) at lib/version/Limit.pm line 57.
BEGIN failed--compilation aborted at -e line 1.

$ perl -Ilib -It -e 'use LimitTest 3.0.0; print "OK!\n"'
OK!

Indeed, you can construct as detailed a hash of compatibilities as your heart
desires, and even internally provide only the interface API that the consumer
requested.  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...

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

John

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