2009/3/18 Moritz Lenz <mor...@faui2k3.org>:
>> +You can leave out the block when matching against a literal value of some
>> +kind:
>> +
>> +    multi sub fib ($n where 0|1) { return $n }
>> +    multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }
>> +
>> +In fact, you can leave out the 'where' declaration altogether:
>> +
>> +    multi sub fib (0) { return 0 }
>> +    multi sub fib (1) { return 1 }
>> +    multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }
>
> As much as I like this new syntax, it's not as useful as it looks.
> multi sub fib (0) desugars to (Any $ where 0),

Shouldn't that desugar to (Int $ where 0)?  After all, 0.WHAT is Int...

Of course, then someone will expect multi sub fib (0|1) { return @_[0]
} to DTRT here...

>
> Cheers,
> Moritz
>



-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to