Is there a straightforward way to check if something is a mixin?

5

Raku mixins have two (or more) natures, combining several values in the same container, or values along with roles. However, there is not, as far as I can tell, a straightforward way to check for "mixinity" in a variable that has not been created by you.

This might be a trick

my $foo = 3 but Stringy;
say $foo.^name ~~ /\+/;# OUTPUT: «「+」␤»

But is there any other property I'm missing that would allow to look this up directly?

Share
Improve this question
2
  • 1
    Hi JJ. Please consider explaining what problem it is you're addressing that leads you to think that the solution is being able to easily know that some value carries a mixin. – raiph Apr 1 at 1:27
  • 1
    Your "trick" introspects a value with a mixin. Introspecting a container with a mixin that's been bound to a variable might be a different incantation (eg using .VAR if it's a Scalar). And introspecting a variable itself would require yet another incantation (using something like .var.VAR). – raiph Apr 1 at 1:40

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

flutter websocket connection issue