Rules / Types, classes & roles / metamodel

Metamodel::C3MRO Reference

Metaobject that supports the C3 method resolution order

What it is #

Position in the hierarchy #

Inherits from
Does
Consumed byMetamodel::ClassHOW, Metamodel::NativeHOW

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 compute_mro #

method compute_mro($type)

Computes the method resolution order.

method mro #

method mro($type)

Returns a list of types in the method resolution order, even those that are marked is hidden.

method mro_unhidden #

method mro_unhidden($type)

Returns a list of types in method resolution order, excluding those that are marked with is 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 doc-drift · 1 no-output · 1 ok

role Metamodel::C3MRO { }

Not executed: the documentation states no expected output for this example.

class CommonAncestor { };   # implicitly inherits from Any
class Child1 is CommonAncestor { }
class Child2 is CommonAncestor { }
class GrandChild2 is Child2 { }
class Weird is Child1 is GrandChild2 { };

say Weird.^mro; # OUTPUT: «(Weird) (Child1) (GrandChild2) (Child2) (CommonAncestor) (Any) (Mu)␤»
Documentation
(Weird) (Child1) (GrandChild2) (Child2) (CommonAncestor) (Any) (Mu)
Rakudo
((Weird) (Child1) (GrandChild2) (Child2) (CommonAncestor) (Any) (Mu))
Raku++
((Weird) (Child1) (GrandChild2) (Child2) (CommonAncestor) (Any) (Mu))

Both engines agree; the documentation states something else. Trust the engines.

say Int.^mro;   # OUTPUT: «((Int) (Cool) (Any) (Mu))␤»
Output
((Int) (Cool) (Any) (Mu))

Documentation, Rakudo and Raku++ all agree.