On Tue, Jan 15, 2008 at 03:48:05PM +0000, Smylers wrote:
> jrod...@hate.spamportal.net writes:
> 
> > On Tue, Jan 15, 2008 at 01:48:40PM +0000, Smylers wrote:
> > 
> > > jrod...@hate.spamportal.net writes:
> > > 
> > > > On Tue, Jan 15, 2008 at 08:09:39AM -0500, Ricardo SIGNES wrote:
> > > > 
> > > > > 1.80 means 1.800000.  1.95.1 means 1.095001.
> > > > 
> > > > How in the nine hells of software hate doesn't it mean 1.950001 or
> > > > some such crap?
> > > 
> > > Because (I believe the reasoning goes) if 1.95.1 mapped to 1.950001 then
> > > what would 1.100.1 map to to ensure it's greater?
> > 
> > But how *doesn't* this apply to 1.80?
> 
> It does if you tell it that 1.80 is a version number.
> 
> But Perl (unsurprisingly) also supports floating-point numbers, for use
> with maths and things like that.  And obviously such numbers need to be
> tret as such, not as version numbers.
> 
> And, unfortunately, Perl (like most other languages) uses the full stop
> rather than the decimal point for floating-point numbers.
> 
> Which means that it has to guess whether 1.80 is a representation of the
> real number 1.8 or a version number where "1" is the first part and "80"
> is the second.  Unless there is any evidence to the contrary it chooses
> the former -- which makes sense, given that computer programs do
> arithmetic much more than they process version numbers.
> 
> v1.80 is unambiguously a version number, because floating point numbers
> don't start with a "v".
> 
> qv(1.80) is unambiguously a version number, because qv() is a function
> which is defined as interpreting its argument as a version number.
> 
> 1.8.1 is unambiguously a version number, because real numbers don't have
> multiple full stops in them.
> 
> 1.8 could be either, so is treated as a floating-point number.

Rubbish.

We're talking about Perl, not some other language. In Perl, how something
is treated doesn't depend on how something looks, but on its context.

   perl -E 'say 1.8 . "a"'

Heh! 1.8 ain't no floating point number, it's a string!


Furthermore, I make my versions typically as follows:

our ($VERSION) = q $Revision: 1.8 $ =~ /[\d.]+/g;

$VERSION is a string. Perl never gets the idea that $VERSION is a
floating point thingy. Yet, as a version, it's treated as a larger version
than 1.799, and a smaller version than 1.801.


Besides, 1.8.1 isn't unambiguously a version number, it can also be 
a string, as the following example shows:

    $ perl -wE 'say 83.109.121.108.101.114.115'
    Smylers

    $ perl -wE 'say v83.109.121.108.101.114.115'
    Smylers


qv() is a function that isn't available by default, it's found in the
version package - so it's only unambiguously if you know that the qv()
you see is an alias for version::qv.

    $ perl -Mversion -wE 'say qv (83.109.121.108.101.114.115)'
    v83.109.121.108.101.114.115
    $ perl -Mversion -wE 'say qv (v83.109.121.108.101.114.115)'
    v83.109.121.108.101.114.115
    $ perl -Mversion -wE 'say qv ("v83.109.121.108.101.114.115")'
    v83.109.121.108.101.114.115
    $ perl -Mversion -wE 'say qv ("83.109.121.108.101.114.115")'
    83.109.121.108.101.114.115


Man, sometimes I feel so tempted to put things like

    $VERSION = 'yellow';

in my modules.


Abigail

Attachment: pgpVNZOLAhMpu.pgp
Description: PGP signature

Reply via email to