On Mon, Apr 19, 2010 at 7:55 AM, Elliot Shank <p...@galumph.com> wrote:
> Oof.  Version numbers: "All components after the first are restricted to the
> range 0 to 999."  That's going to be a problem for those of us who include
> things like VCS revisions and CI build numbers in version numbers.

You can do that as long as you use regular decimals and not dotted-decimals.

Dotted-decimals have a "round-trip" problem when being compared to
decimals.  Depending on the order that things are converted, you can
get different answers.

Consider "v1.2.1000.3".  How should that be converted to a decimal
version?  Following the rule that every dotted component after the
first is multiplied by 10e-(3*n), you might think 1 + 2 * 0.001 + 1000
* 0.000001 + 3 * 0.000000001 or 1.003000003.  But if you ask
version.pm to numify it, you get this:

    $ perl -Mversion -wE 'say version->new("v1.2.1000.3")->numify'
    1.0021000003

Now consider how version.pm converts those decimals back to dotted form:

    $ perl -Mversion -wE 'say version->new("1.0021000003")->normal'
    v1.2.100.0.300

    $ perl -Mversion -wE 'say version->new("1.003000003")->normal'
    v1.3.0.3

Not all parts of the toolchain support prerequisites specified in
dotted decimal form.  How will users convert to decimal?  We can't
know.  Perl itself will interpret dotted decimals slightly differently
in "use NAME VERSION" depending on the version of Perl.  If a module
uses dotted decimals, are the user putting the dotted decimal on the
"use" line or a decimal version?  If a decimal version, which one?

The rule in the CPAN Meta Spec that limits dotted decimal components
after the first to the range 0 to 999 is designed to ensure
unambiguous interoperability.  CPAN Authors are free to use dotted
decimals outside that range, but any spec that contains them will be
treated as invalid.

-- David

Reply via email to