> On 21 Aug 2021, at 20:03, Joseph Brenner <doom...@gmail.com> wrote: > > Given and example like this: > > class A {} > class B is A {} > class D is B {} > > say D.^parents(); # ((B) (A)) > say D.^parents( :all ); # ((B) (A) (Any) (Mu)) > > So, I conclude that Any and Mu are "hidden" as far as ^parents is concerned. > > According to the documentation, ^mro_unhidden does this: > > "Returns a list of types in method resolution order, excluding > those that are marked with is hidden." > > And yet, what I see is: > > say D.^mro_unhidden; # ((D) (B) (A) (Any) (Mu)) > > So why does this include Any/Mu?
Good question, I don't have an answer handy. > A somewhat related question: How do you check whether a trait is set > on something? > Can you get a list of all traits? No. A trait is nothing else than a piece of code that gets executed at compile time with the object to which it is applied as the parameter (and the value specified with the trait). Whatever the code of that trait actually does, is up to that trait. Most traits mix in a role into the object, but not all. For instance, the "is hidden-from-backtrace" trait on subroutines and methods, mixes in a role: multi sub trait_mod:<is>(Routine:D $r, :$hidden-from-backtrace!) { $r.^mixin( role is-hidden-from-backtrace { method is-hidden-from-backtrace(--> True) { } }) if $hidden-from-backtrace; } But others, like the "is rw" trait on an attribute, just calls a method on the Attribute object. multi sub trait_mod:<is>(Attribute:D $attr, :rw($)!) { $attr.set_rw(); warn "useless use of 'is rw' on $attr.name()" unless $attr.has_accessor; } So there is no generic way to tell what traits have been applied to an object. Liz