On Mon, May 18, 2009 at 9:32 AM, John Peacock
<john.peac...@havurah-software.org> wrote:
> The code you committed is actually more complicated than it needs to be:
>
>> === lib/Module/Build/Base.pm
>> ==================================================================
>> --- lib/Module/Build/Base.pm    (revision 2562)
>> +++ lib/Module/Build/Base.pm    (local)
>> @@ -3620,9 +3620,7 @@
>>   }
>>   elsif ( ref $version eq 'version' ||           ref $version eq
>> 'Module::Build::Version' ) { # version objects
>> -    my $string = $version->stringify;
>> -    # normalize leading-v: "v1.2" -> "v1.2.0"
>> -    $version = substr($string,0,1) eq 'v' ? $version->normal : $string;
>> +    $version = $version->is_qv ? $version->normal : $version->stringify;
>>   }
>>   elsif ( $version =~ /^[^v][^.]*\.[^.]+\./ ) { # no leading v, multiple
>> dots
>>     # normalize string tuples without "v": "1.2.3" -> "v1.2.3"
>
> Of course I cheated and used the undocumented (until now that is)
> $obj->is_qv method, which is true for extended versions (henceforth to be
> referred to as dotted-decimal).

I don't seem to have is_qv:

  $ perl -Mversion -E '$v=version->new(1.2); say $v; say $v->is_qv'
  1.2
  Can't locate object method "is_qv" via package "version" at -e line 1.

> I also wonder why you didn't use:
>
>        elsif ($version->isa('version') {
>
> which protects against other version.pm-derived classes which would
> otherwise continue through unmolested...

Simple answer: I didn't want to write "ref $version &&
ref($version)->isa('version')" or "blessed $version &&
$version->isa('version')" or UNIVERSAL::isa($version, 'version') or
have to remember which is correct or likely to break.

More considered answer -- if it isn't a version.pm object, it should
probably just die, since nothing else is a "canonical" version and we
don't want to support "v1.2b" going forward anyway.

-- David

Reply via email to