Is it okay to name the ":isa" attribute for single inheritance? #72
-
Is it okay to name the ":isa" attribute for single inheritance? https://github.com/Ovid/Cor/blob/master/rfc/classes.md#422-inheritance
The reason I ask this question is Perl has already "isa" operator.
"isa" operator check @isa in both single inheritance and multiple inheritance. And if the role is implemented internally using multiple inheritance, the result of "isa" operator maybe be true.
people may ask. "Why does the isa operator return true even though the ":isa" attribute is not specified?" |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In short: It is ok to name the ":isa" attribute for single inheritance. Both the attribute and the operator can be read like "is a" in English to give the correct understanding. A customer is a person - makes sense. "is a" expects singular terms on both sides. In your example A corresponding |
Beta Was this translation helpful? Give feedback.
In short: It is ok to name the ":isa" attribute for single inheritance.
Both the attribute and the operator can be read like "is a" in English to give the correct understanding. A customer is a person - makes sense. "is a" expects singular terms on both sides.
In your example
if ($object isa Role1)
the code will not return true:Role1
is not a class, and not added to the@ISA
ofMyClass
. With Corinna this could be caught as a syntax error because Corinna roles identify themselves at compile time. Applied to a role implemented withMoose::Role
,isa Role
simply returns false.A corresponding
does
operator in Perl does not yet exist because Perl core does not have roles (yet).