# New Ticket Created by  Damian Conway 
# Please include the string:  [perl #121454]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=121454 >


On the 2014.01 release of Rakudo, this works as expected:

    subset Zero of Int where 0;
    subset One  of Int where 1;

    multi fib (Zero)    { 1 }
    multi fib (One)     { 1 }
    multi fib (Int $n)  { fib($n-1) + fib($n-1) }

    say fib(3);

And we can then reduce the syntactic load by "inlining" the constraint:

    multi fib (0)       { 1 }
    multi fib (1)       { 1 }
    multi fib (Int $n)  { fib($n-1) + fib($n-1) }

    say fib(3);

Which also works under 2014.01.

Or we could have optimized the syntax with a junctive constraint instead:

    subset ZeroOne of Int where 0|1;

    multi fib (ZeroOne) { 1 }
    multi fib (Int $n)  { fib($n-1) + fib($n-1) }

    say fib(3);

Which also works under 2014.01.

So then I wanted to use the final syntactic optimization: once again
"inlining" the constraint:

    multi fib (0|1)     { 1 }
    multi fib (Int $n)  { fib($n-1) + fib($n-1) }

    say fib(3);

But that doesn't even compile. :-(
I believe it should.
And it would also be very convenient--for my purposes of one-upping
Haskell--if it did. :-)

Thanks,

Damian

Reply via email to