This code works as expected:
sub infix:<mean>(*@a) {
@a.sum / @a.elems
}
sub Mean (*@a) {
@a.sum / @a.elems
}
say EVAL 'Mean 2, 6, 4'; # Output: 4
say EVAL '2 mean 6 mean 4'; # Output: 4
It works as expected when line 7 is in its own scope:
{say EVAL 'Mean 2, 6, 4';} # Output: 4
But when line 8 is in its own scope:
{say EVAL '2 mean 6 mean 4';}
===SORRY!=== Error while compiling .../EVAL_1
Two terms in a row
at .../EVAL_1:1
------> 2⏏ mean 6 mean 4
expecting any of:
infix
infix stopper
statement end
statement modifier
statement modifier loop
Why are the two subs treated differently?