In reference to this question / answer, perl6 multi defaults to sub.
No such method <name> for invocant of type <class>
I would have expected it to default to method. Please could someone explain the rationale for this?
A multi declarator (multi
, proto
, or only
) that is not followed by some other kind of declarator, but instead a routine name, will always be short for the sub
declarator.
Perl 6 is keen on lexical scoping, and especially keen on making code easy to refactor.
Making the shortest way to declare a multi
take the most narrowly scoped option - lexical scope - encourages keeping things as narrowly scoped as possible.
Making multi
without a declarator have a consistent meaning aids refactoring, by allowing one to confidently move the code to the narrowest scope in which it is required. Having it suddenly change meaning just because it was moved into a class
would be a refactoring frustration.
Finally, it's worth noting that sub
in Perl 6 can be seen as filling the same niche as private static
in various other languages, that multiple dispatch is generally useful, and thus a multiple dispatch sub
can therefore be useful inside of a class
body.
Sometimes special cases are justified. Like natural languages, Perl 6 will make them when it's really worth it, but the default is to avoid them. The argument for multi
meaning something else inside of a class
(and presumably role
) just isn't strong enough for a special case.