Keep It Simple, Stupid | |
PerlMonks |
Re^5: Introspection of Moose/Mouse attributes fails to find native trait with `does`by ikegami (Patriarch) |
on Aug 24, 2011 at 23:36 UTC ( [id://922227]=note: print w/replies, xml ) | Need Help?? |
Perl says:
One must assume that types are roles for this definition to be equivalent to yours. Similarly, you can only use Liskov's substitution principle's to justify DOES using ISA if you assume 1) that the principle applies to roles as well as types, and 2) that types are roles. I agree that the principle applies to roles, but I'm not convinced that types are necessarily roles. Is there anything to support this assumption? Back on subject, I went beyond a glance and came up with a researched answer. Moose attributes don't have a type. isa specifies a type constraint, not a type. The value held by an instance of the attribute has a type, but does is a method of the attribute. How then can does check the type of the attribute if the attribute doesn't have a type? does "indicates whether the attribute itself does the given role. The role can be given as a full class name, or as a resolvable trait name. Note that this checks the attribute itself, not its type constraint, so it is checking the attribute's metaclass and any traits applied to the attribute." (Emphasis in original.)
In Section
Seekers of Perl Wisdom
|
|