Stephen Simmons (via RT) wrote:
> # New Ticket Created by  Stephen Simmons 
> # Please include the string:  [perl #58282]
> # in the subject line of all future correspondence about this issue. 
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58282 >
> 
> 
> I wrote a two argument max function, which uses an if/elsif/elsif/else  
> tree; the third case in the statement fails, the rest succeed.
> 
> The code is:
> 
> sub max($a, $b) {
>       if defined $a && defined $b {
>               if $a >= $b { return $a } else { return $b }
>       }
>       elsif defined $a { return $a }
>       elsif defined $b { return $b }
>       else { return undef }
> }
> 
> say "1 <" ~ max(3, 4) ~ ">";
> say "2 <" ~ max(4, 3) ~ ">";
> say "3 <" ~ max(-4, undef) ~ ">";
> say "4 <" ~ max(undef,-2) ~ ">";
> say "5 <" ~ max(undef, undef) ~ ">";
> 
> The output is (except for the comment):
> 
> sully:parrot-0.7.0 stephensimmons$ perl6 ../experiment/max.p6
> 1 <4>
> 2 <4>
> 3 <>       # should have returned -4, similar to test 4, next.
> 4 <-2>
> 5 <>

in trunk, r31178 this gives the desired output (specifically '3 <-4>'),
so I'll close this ticket.

(I suspect it was either a problem with defined() which was improved
lately, or a parsing problem).


-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/

Reply via email to