Raku / problem-solving

🦋 Problem Solving, a repo for handling problems that require review, deliberation and possibly debate
Artistic License 2.0
70 stars 16 forks source link

"Endpoint" methods should not have `*%_` in their signature #444

Open lizmat opened 1 month ago

lizmat commented 1 month ago

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:

% 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:

% raku -e 'my $n = 3; say (^10).head' 
0