Metamodel::MROBasedMethodDispatch Reference
Metaobject that supports resolving inherited methods
What it is #
Position in the hierarchy #
| Inherits from | — |
| Does | — |
| Consumed by | Metamodel::ClassHOW, Metamodel::EnumHOW, 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 find_method #
method find_method($obj, $name, :$no_fallback, *%adverbs)
Given a method name, it returns the method object of that name which is closest in the method resolution order (MRO). If no method can be found, it returns a VM-specific sentinel value (typically a low-level NULL value) that can be tested for with a test for definedness: If :no_fallback is supplied, fallback methods are not considered.
method find_method_qualified #
method find_method_qualified($obj, $type, $name)
Given a method name and a type, returns the method from that type. This is used in calls like
method can #
method can($obj, $name)
Returns the list of methods of that name the object can do.
method publish_method_cache #
method publish_method_cache($obj)
Walk MRO and add methods to cache, unless another method lower in the class hierarchy "shadowed" it.
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.
3 no-output
role Metamodel::MROBasedMethodDispatch { }Not executed: the documentation states no expected output for this example.
for <uppercase uc> {
Str.^find_method: $^meth andthen .("foo").say
orelse "method `$meth` not found".say
}
# OUTPUT:
# method `uppercase` not found
# FOONot executed: the documentation states no expected output for this example.
self.SomeParentClass::the_method();
Not executed: the documentation states no expected output for this example.