I've written at length how I wish version numbers were boring and why they aren't. What I haven't done well is to express what I think that means. In some recent conversations on the perl5-porters mailing list and #p5p on IRC, I took a stab at a definition, which I'll repost here.
In part, my "wishlist" is to harmonize how $VERSION is defined, how $VERSION is statically parsed by ExtUtils::MM->parse_version and Module::Build::ModuleInfo, how $VERSION is specified to use(), what gets returned by UNIVERSAL::VERSION and what version->new($version) gives.
I'd like to be able to "round-trip" a version any which way.
- set it via package NAME VERSION
- statically parse it and get the same thing back
- eval "use Foo $version" and succeed
- get the same thing back from Foo->VERSION
- give it to version->new() and get back the same thing.
I've posted a test file that demonstrates these desired behaviors using the new 'package NAME VERSION' syntax in Perl 5.11.2.
Here are some of the things that don't work:
- '01.23' -- this is interpreted as an octal. Oops!
- '1_000' -- statically parsed with the underscore, but interpreted without by 'use NAME VERSION', and version.pm doesn't like it at all
- 'v1.1000.2345' -- dotted integer components over 999 bleed over into the next field when converted to decimal, so this is really equivalent to decimal version 2.002345
- 'v1.2_3' -- is this an "alpha" like v1.2.3 or is this v1.23.0? Depending how this is expressed it can be interpreted either way
- '1.23_01' -- a good old fashioned "alpha" decimal version -- but again, it parses statically one way but is interpreted another.
It's very possibly I'm being too draconian -- my wishlist means alpha version numbers would go away entirely (and would have to be replaced with something else, certainly.) But if I had to start over, these criteria would make version numbers much easier to deal with.