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 version.pm, 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 version.pm 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 version.pm (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 version.pm 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 version.pm 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 version.pm?


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 version.pm 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'
2.001
perl-5.6.1 -Mversion -le '$x = version->new(2.000_1); print $x'
2.0.100

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: http://search.cpan.org/dist/version/lib/version.pm#What_about_v-strings?

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 version.pm 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'
0.000

version.pm 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'
1
perl-5.6.1 -Mversion -le '$x = 2.002_003; print $x > 2.002     ? 1 : 0'
1

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 version.pm. 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 version.pm 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 version.pm 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 version.pm or can get away w/o it.



-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to