perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip M. Gollucci" <pgollu...@p6m7g8.com>
Subject Re: -Wdeclaration-after-statement Final version
Date Tue, 23 Aug 2005 03:33:22 GMT
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.

> 
> Minor nit, but wouldn't
> 
> my @tuples = split /\./, $has_version;
> my @r_tuples = split /\./, $requested_version;
> 
> return cmp_tuples(\@tuples, \@r_tuples) == 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 should be
 >         return $cmp if $cmp;
return 1 if $cmp == 1;

Whith that minor change, I agree.

-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message