Metamodel::MultipleInheritance Reference
Metaobject that supports multiple inheritance
What it is #
Position in the hierarchy #
| Inherits from | — |
| Does | — |
| Consumed by | Metamodel::ClassHOW, Metamodel::ConcreteRoleHOW, Metamodel::NativeHOW, Metamodel::ParametricRoleHOW |
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method add_parent #
method add_parent($obj, $parent, :$hides)
Adds $parent as a parent type. If $hides is set to a true value, the parent type is added as a hidden parent. $parent must be a fully composed typed. Otherwise an exception of type X::Inheritance::NotComposed is thrown.
method ^parents #
method ^parents($obj, :$all, :$tree)
Returns the list of parent classes. By default it stops at Cool, Any or Mu, which you can suppress by supplying the :all adverb. With :tree, a nested list is returned.
method hides #
method hides($obj)
Returns a list of all hidden parent classes.
method hidden #
method hidden($obj)
Returns a true value if (and only if) the class is marked with the trait is hidden.
method set_hidden #
method set_hidden($obj)
Marks the type as hidden.
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
1 all-differ · 2 no-output
role Metamodel::MultipleInheritance {}Not executed: the documentation states no expected output for this example.
class D { };
class C1 is D { };
class C2 is D { };
class B is C1 is C2 { };
class A is B { };Not executed: the documentation states no expected output for this example.
say A.^parents(:all).raku; # OUTPUT: «(B, C1, C2, D, Any, Mu)» say A.^parents(:all, :tree).raku; # OUTPUT: «[B, ([C1, [D, [Any, [Mu]]]], [C2, [D, [Any, [Mu]]]])]»
(B, C1, C2, D, Any, Mu)
[B, ([C1, [D, [Any, [Mu]]]], [C2, [D, [Any, [Mu]]]])]
(Mu,)
(Mu,)
All three differ. Needs a human.
Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.