Philip M. Gollucci wrote: > Philippe M. Chiasson wrote: > >> Isn't "return;" the more canonical way of returning false ? > > Beats me... I know a lot of the mp2 code particular Apache2::Status as I > was just digging in there uses return 0. I really have no preference.
Just looked around the existing code, and yes, you are right, return 0 is
used all over to represent failure, so I guess it's better to be consistent.
>> Minor nit, but wouldn't
>>
>> my @tuples = split /\./, $has_version;
>> my @r_tuples = split /\./, $requested_version;
>>
>> return cmp_tuples([EMAIL PROTECTED], [EMAIL PROTECTED]) == 1;
>>
>> sub cmp_tuples {
>> my ($a, $b) = @_;
>>
>> while(@$a && @$b) {
>> my $cmp = shift @$a <=> shift @$b;
>> return $cmp if $cmp;
>> }
>> return @$a <=> @$b;
>> }
>>
>> Be a more generic approach that would also work if there is ever a
>> gcc-4.0.0.1 and could possibly be used to refactor some more version
>> comparaisons ?
>
> More generic yes. But working no. :)
>
> <=> returns 1, 0, -1, and undef for NaN.
> both 1 and -1 are true in perl.
That was by design, to keep the behaviour of <=> or cmp
> That should be
>> return $cmp if $cmp;
> return 1 if $cmp == 1;
>
> Whith that minor change, I agree.
You must have missed this bit:
return cmp_tuples([EMAIL PROTECTED], [EMAIL PROTECTED]) == 1;
Where I specifically check that @tuples is greater than @r_tuples.
Figured this cmp_tuples() migth also be used to check if something
is less than something else.
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
signature.asc
Description: OpenPGP digital signature
