problem-solving
problem-solving copied to clipboard
Signature parameter introspection for type smileys/signature modifiers
I see no way of finding if a parameter is definite, in roast, unless I missed it. Raku docs don't have any information about it either.
The only way I found that works(I think!) is smartmatching against a Parameter. Maybe there is another way that I'm not aware of.
Example:
sub f (Int:D $x) {};
say :(Int:D).params[0] ~~ &f.signature.params[0] # True
I don't know if this is the solution, but Rakudo has a modifier method for Parameter class:
sub f (Int:D $x) {};
say &f.signature.params[0].modifier # :D
+1 to the idea of adding Rakudo's Parameter.modifier to Roast. It's been present (and fairly stable) since 2016, it's not marked as an implementation detail, and it's consistent with the other Parameter methods.