If a method is sure to not be calling any other methods, then it should have the option of not automatically codegenning the *%_ in their signature. If that was done for the .head method, then this example would fail with a very useful error:
% raku -e 'my $n = 3; say (^10).head:$n'
Cannot resolve caller head(Range:D, :n(Int)); none of these signatures matches:
($head, +values)
as opposed to just silently do the wrong thing:
% raku -e 'my $n = 3; say (^10).head:$n'
0
because the :$n silently gets eaten, so it works as:
As again pointed out in https://github.com/rakudo/rakudo/issues/2368.
If a method is sure to not be calling any other methods, then it should have the option of not automatically codegenning the
*%_
in their signature. If that was done for the.head
method, then this example would fail with a very useful error:as opposed to just silently do the wrong thing:
because the
:$n
silently gets eaten, so it works as: