Have I told you how wonderful I think Raku is?
Well I don't have enough words to do that.
However even the best languages have thier faults, and one of Raku's the following:
sub a ( :name(:named(:$names)) ) { ... }
The above describes a sub thats has a single named parameter with two aliases. That's a bit hard to read.
Now I tried to do something different based on inspiration from lizmat's Method::Also:
role AttributeAlso[@aliases] {
method named_names {
|@aliases.reverse, self.name.substr(1);
}
}
multi sub trait_mod:<is>(Parameter:D \param, :$also!) is export {
say "Aliasing { param.^name }";
param does AttributeAlso[$also]
}
Which does what it looks to do...
$raku -Ilib -e 'use Method::Also; class A { method a (:$names is also<name named>) { &?ROUTINE.signature.params.skip(1).head.named_names.gist.say; $names.say } }; A.a(named=>1)'
Aliasing Parameter
(named name names)
(Any)
However, setting the aliases in the meta-model doesn't appear to be enough to actually set the value.
Can anyone tell me what I'm missing?
Looks like
named_names
is only informational. I guess you'd have to look in the grammar / actions to see how such named parameters are actually set up / codegenned.