Skip Menu |

This queue is for tickets about the version CPAN distribution.

Report information
The Basics
Id: 45138
Status: resolved
Priority: 0/
Queue: version

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.76
Fixed in: (no value)



Subject: Special case +0
$foo+0 is the simple convention for forcing numeric context. Unfortunately... $ perl -wle 'use version; print qv(1.2.3)+0' operation not supported with version object at -e line 1. Rather than having to do special case detection for version objects before trying to numify, it would be nice if adding 0 was allowed to mean ->numify. Extending this further, since version objects do have a numeric value there's no real reason all math shouldn't work on them, but I'd understand not wanting to go that far. Let me know if this is sane and I'll work up a patch.
Subject: Re: [rt.cpan.org #45138] Special case +0
Date: Sun, 19 Apr 2009 06:51:33 -0400
To: bug-version [...] rt.cpan.org
From: John Peacock <john.peacock [...] havurah-software.org>
Michael G Schwern via RT wrote: Show quoted text
> $foo+0 is the simple convention for forcing numeric context. > Unfortunately... > > $ perl -wle 'use version; print qv(1.2.3)+0' > operation not supported with version object at -e line 1.
That was a conscious choice. What does this mean? qv(1.2.3)+1; I chose not to support any mathematical operations on base version.pm objects because there is no easily explainable mode of operation at hand. Show quoted text
> Rather than having to do special case detection for version objects > before trying to numify, it would be nice if adding 0 was allowed to > mean ->numify.
The problem is that I think you are using the wrong tool. ->numify is an internal method to produce an equivalent value that can be used for comparison, but it is not the same _thing_ as the underlying object. As I just said on the Module::Build list, stringification preserves the author's /intent/, rather than enforcing some specific interpretation of that intent. This will always work: $VERSION = qv(1.2.3); ...later... print "$VERSION"; in that it will return what the author typed. Use version.pm objects for version comparisons, but if you have to, use the stringified representation for output purposes... John
Closing WONTFIX. I think I made my argument on the M::B list that I think this is the wrong route to get to the solution you want. The change to M::B's META.yml generation fixes it the way that make the most sense to me. Thanks for caring enough to enter the ticket though. I learn more from people who are willing to disagree with me than from people who don't say anything at all... ;-)