Front page | perl.perl5.porters |
Postings from July 2009
Re: A Modest Proposal
From: John Peacock
July 22, 2009 21:03
Re: A Modest Proposal
Message ID: 4A67E11F.email@example.com
On 7/22/09 7:20 PM, David Golden wrote:
> My gut reaction is "not quite". I have several reasons. (And damn, I
> really, really, need to finish my article on version numbers.)
> At very least, it needs to be quoted:
> use version; our $VERSION = "v1.2.3";
> use version; our $VERSION = "1.002003";
> You need to do this because of alpha versions. There are subtle ways
> it will break or do unexpected things if you use bare v-strings.
> I also *strongly* advocate only teaching people to use leading "v".
> It clearly disambiguates the cases visually between version tuples and
> decimals. Yes, the internals should be liberal in what they accept,
> but code examples should teach that.
I can live with both of those in the documentation. I was really
arguing that it would be a good thing that to just 'use version' and
then assign something to $VERSION and everything else would JUST WORK.
> I think this is how it should have been done in the first place,
> except that it should NON-DESTRUCTIVELY convert them to version
> objects for comparison.
Actually that is what it does already. The current 5.10.0
UNIVERSAL::VERSION, which is to say the version.pm UNIVERSAL::VERSION
will transparently upgrade either left or right term in order to perform
the comparison, but does it on a temporary copy.
> I'm actually a step ahead of you in one respect. I have a working
> blead patch that extends the package keyword in this way:
> package Foo v1.2.3;
> package Bar 1.002003;
> The numbers are parsed using the exact same code that is used for "use
> MODULE VERSION" and stored in the appropriate package's $VERSION
> This of course would require perl 5.12, so doesn't help older perls,
> but going forward it means that version numbers become literals, not
> runtime expressions. Thus, MM->parse_version can parse it directly
> and avoid having to eval() an arbitrary string. I think this is a
> cleaner long-term interface than "use version; our $VERSION...".
But you have just describe two completely different version styles, so I
don't think that MM->parse_version can just parse it, but in essence,
this would be better than the existing regex/eval method.
> I'd like to go further on two topics:
> (1) The pure-Perl version.pm code should remove the module autoloading
> in UNIVERSAL::VERSION. From what I can tell with my pidgin XS,
> neither the 5.10 core UNIVERSAL::VERSION nor the code in version::vxs
> does that. If so, neither should version::vpp.
> (2) Alpha versions should compare equal to a non-alpha version with
> the same tuple components. Once version.pm decides that something is
> an alpha, it's not easy/obvious how someone can require that version
> in a "use MODULE VERSION" line. "use Foo 0.001_002" won't work
> because Perl drops the underscore. And "use Foo v0.1_2" has behavior
> that varies a bit depending on what version of perl is used. I
> strongly feel that it's more user-friendly to leave "alpha" purely as
> a PAUSE/CPAN distinction and not make users have to figure out the
> right incantation on a use() line.
I need to unpack that and work through it. Can you give me an example
of where the alpha version should or should not be considered equivalent
on the 'use module \d+\.\d+' line?