Skip Menu |

This queue is for tickets about the version CPAN distribution.

Report information
The Basics
Id: 86586
Status: rejected
Priority: 0/
Queue: version

People
Owner: jpeacock [...] cpan.org
Requestors: onken [...] netcubed.de
Cc:
AdminCc:

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



Subject: ->numify doesn't always return a number
$ perl -Mversion -w -E "print version->parse('v0.9_9')->numify+0" Argument "0.009_009" isn't numeric in addition (+) at -e line 1. Seems wrong to me.
numify() doesn't magically convert version objects to numbers; it returns what would be an equivalent representation if typed manually. What I mean by that is if you typed 0.009_009 into a script (with no quoting at all), the Perl parser would interpret that as 0.009009 (i.e. it would ignore any underscores). I specifically wrote numify to preserve the underscores in the case of alpha versions. I also specifically decided that it would be illegal to perform mathematic operations on base version objects. In general, if you think you need to use numify() for version objects, you probably aren't using version objects appropriately. John
On Sat Jul 06 15:17:25 2013, JPEACOCK wrote: Show quoted text
> numify() doesn't magically convert version objects to numbers; it > returns what would be an equivalent representation if typed > manually. What I mean by that is if you typed 0.009_009 into a > script (with no quoting at all), the Perl parser would interpret > that as 0.009009 (i.e. it would ignore any underscores). I > specifically wrote numify to preserve the underscores in the case > of alpha versions. I also specifically decided that it would be > illegal to perform mathematic operations on base version objects. > > In general, if you think you need to use numify() for version objects, > you probably aren't using version objects appropriately. > > John
This code is used by metacpan.org to convert a version in a true number. Our backend expects numbers so we can sort and filter on them.
On Mon Jul 08 05:36:28 2013, PERLER wrote: Show quoted text
> This code is used by metacpan.org to convert a version in a true > number. Our backend expects numbers so we can sort and filter on them.
Versions are not numbers. By stripping the underscore from an alpha version, you would be losing information. The whole reason for version.pm to exist is to compare versions in a sane and consistent fashion. If your backend is Postgres, can I suggest this instead? http://pgxn.org/dist/semver/doc/semver.html I'm sorry but I am not going to change numify(); it is trivially easy to subclass version.pm so you can override numify and strip out the underscores if that is what you really want to do. John
On Mon Jul 08 07:29:59 2013, JPEACOCK wrote: Show quoted text
> On Mon Jul 08 05:36:28 2013, PERLER wrote:
> > This code is used by metacpan.org to convert a version in a true > > number. Our backend expects numbers so we can sort and filter on
> them. > > Versions are not numbers. By stripping the underscore from an alpha > version, you would be losing information. The whole reason for > version.pm to exist is to compare versions in a sane and consistent > fashion. > > If your backend is Postgres, can I suggest this instead? > > http://pgxn.org/dist/semver/doc/semver.html > > I'm sorry but I am not going to change numify(); it is trivially easy > to subclass version.pm so you can override numify and strip out the > underscores if that is what you really want to do. > > John
No worries. I just wasn't sure whether that behavior was by design.