problem-solving icon indicating copy to clipboard operation
problem-solving copied to clipboard

Signature parameter introspection for type smileys/signature modifiers

Open CIAvash opened this issue 4 years ago • 2 comments

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

CIAvash avatar Oct 09 '21 12:10 CIAvash

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

CIAvash avatar Oct 09 '21 12:10 CIAvash

+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.

codesections avatar Nov 09 '21 14:11 codesections