perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: version syntax for mp2
Date Sun, 12 Dec 2004 23:01:36 GMT
John Peacock wrote:
> Stas Bekman wrote:
>> [CC'ing John <the version guru> Peacock]
>> John, I think we need your help here, see the story below. But in 
>> short we
>> want to start using triplet versioning for modperl 2.0.x and we don't 
>> want to
>> require, since so far we don't have any external 
>> dependencies. Can
>> we do that? mp2 requires 5.6.1+.
> The short answer is that if you want to use triplet versioning in Perl 
> the only consistent way to do it is using the module.  Trying 
> to manage it with the inconsistent way that Perl handles v-strings isn't 
> going to be pretty.
> I could give you a pure-Perl (which I have been meaning to 
> write anyway) that you can include in the mp2 distro or you add 
> version.xs to the collection of core mp2 files.  The file 
> itself is only documentation (and bootstrap loader).  Since mp2 already 
> requires a compiler, it doesn't do you any harm to add another xs file.  
> You can think of it like the ppperl.h file add compatibility #define's 
> for prior Perl releases.

Suppose we bundle in some way with mp2. How is this going to 
help other modules. Let's say I have a module Foo that requires mp2. How 
will it check the required version w/o

> More comments inline below...
>>> What do you mean? That:
>>> if ($mod_perl::VERSION > 1.99)
>>> won't work for $mod_perl::VERSION = v2.0.0?
> You want to be very careful what you use for $mod_perl::VERSION itself, 
> because the use of v-strings (like v2.0.0) is highly dependent on which 
> version of Perl you are running.  From 5.6.0 to 5.8.0, the behavior is 
> one way, from 5.8.1 on it is another.  No matter what you use for 
> version comparisons, it would be best to set the $VERSION scalar in 
> Mod::Perl itself to 2.00_00 or require the use of overloaded version 
> objects (like provides).

2.00_00? That will make PAUSE skip indexing of the package, due to _.

Also didn't you mean 2.000_000 (notice the extra zero):

perl-5.6.1 -Mversion -le '$x = version->new(2.00_1); print $x'
perl-5.6.1 -Mversion -le '$x = version->new(2.000_1); print $x'

John, do you have any good examples on CPAN that use triplets version 
numbers (but not vX.Y)

>>> you are right that we need to play with the version numbers. I'm a 
>>> bit confused at how we do the right triplet VERSION. According to: 
>>> it should be:
>>> $x::VERSION = 2.2.1
>>> but I can't even dump this value, with print.
> That will work only with Perl 5.8.1 or better, because that is the first 
> Perl release which supported magic v-strings.  And even in those cases, 
> without the compatibility layer loaded, you have to use
>     print "%vd", $x::VERSION;
> in order to get the "2.2.1" representation.

Hmm, I'd have thought that it should work with any perl with version, but 
this doesn't work:

perl-5.6.1 -Mversion -le '$x = version->new(2.0.1); print $x'

>>> is a part of the core only from 5.9.x, and we can't 
>>> require it
>>> just to get the version number set.
>>> I've also tried 2.002001 but it doesn't seem to make a very good work 
>>> when
>>> used in conditionals.
> This is the other way to handle it.  If you always refer to $VERSION's 
> by their floating-point equivalent,

You mean 2.000_000? like:

perl-5.6.1 -Mversion -le '$x = 2.002_003; print $x > 2.002_002 ? 1 : 0'
perl-5.6.1 -Mversion -le '$x = 2.002_003; print $x > 2.002     ? 1 : 0'

I guess this could have worked for us. So modules could check:

- require 2.x

   if ($mod_perl::VERSION >= 2)

- require 2.2.x

   if ($mod_perl::VERSION >= 2.002)

- require 2.2.5

   if ($mod_perl::VERSION >= 2.002_005)

and this should continue working in 5.10, right?

> it will work in all versions of Perl 
> without using any compatibility module like  The following 
> version notations are in all ways equivalent (with the caveat for the 
> last):
>     $VERSION = 2.002_001; # the underscore is ignored by the parser
>     $VERSION = version->new("2.2.1"); # with use version;
>     $VERSION = version->new(2.2.1); # only with Perl >= 5.8.1
> However, only the use of something very much like will allow 
> you to easily present a version triplet to the external world (like 
> Apache's own versioning scheme does).
> I know you don't want to add an external requirement if you don't have 
> to, but by far the easiest way to handle version comparisons in a 
> compatible way for a wide range of Perl releases is through the 
> compatibility layer.
> Let me know if there is anything else I can do to help.

Thanks for the detailed explanations, John. I guess one you answer on a 
few more questions I've posed above, it'll be easier to decide whether 
have to bundle or can get away w/o it.

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message