# New Ticket Created by "brian d foy"
# Please include the string: [perl #132713]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=132713 >
I originally asked this on StackOverflow:
https://stackoverflow.com/q/48219788/2766176
This fails to be right associative:
sub infix:<↑> ( Int:D \n, Int:D \m --> Int:D )
is assoc<right>
is equiv(&infix:<**>)
{ n ** m }
put "2**2**2**2 = ", 2**2**2**2;
put "2↑2↑2↑2 = ", 2↑2↑2↑2;
put "2↑ (2↑ (2↑2) ) = ", 2↑ (2↑ (2↑2) );
Reversing the traits fixes that:
sub infix:<↑> ( Int:D \n, Int:D \m --> Int:D )
is equiv(&infix:<**>)
is assoc<right>
{ n ** m }
I didn't see anything in the docs about the ordering of traits but
I wouldn't expect order to matter. Neither did I see anything saying I
couldn't combine traits.
As far as I can tell the precedence still works when it's specified first:
sub infix:<↑> ( Int:D \n, Int:D \m --> Int:D )
is equiv(&infix:<**>)
is assoc<right>
{ n ** m }
put "2↑3**4↑2 = ", 2↑2**2↑2;
put "2↑(3**(4↑2)) = ", 2↑2**2↑2;
put "2↑3*4↑2 = ", 2↑2*2↑2;
put "(2↑2)*(2↑2) = ", (2↑2)*(2↑2);
put "2↑3+4↑2 = ", 2↑2+2↑2;
put "(2↑2)+(2↑2) = ", (2↑2)+(2↑2);
How is this supposed to work? Should either way work? I can easily
imagine situations where I want to stack many traits:
sub infix:<↑> ( Int:D \n, Int:D \m --> Int:D )
is equiv(&infix:<**>)
is assoc<right>
is pure
is export
{ ... }