Introspecting NQP roles

104 Views Asked by At

From this question in StackOverflow, I discovered Type.^roles, which includes all roles that are composed into a type. It works all over the place, but it fails to print if there are NQP roles somewhere:

 say Cursor.^roles# OUTPUT: «No such method 'gist' for invocant of type 'NQPMatchRole'. Did you mean 'ast'?␤  in block <unit> ␤␤»

There's no method gist or Str. However, ^name seems to work:

my @cursor-roles = Cursor.^roles; print $_.^name for @cursor-roles ; # OUTPUT: «NQPMatchRole»

Can I assume NQP roles follow the same metamodel as Perl 6, and I can at least use the ^name? Is there a more general way of printing all roles, including both Perl 6 and NQP roles?

0

There are 0 best solutions below