Metamodel::MethodDelegation Reference
Metarole for delegating method dispatch
What it is #
Position in the hierarchy #
| Inherits from | — |
| Does | — |
| Consumed by | Metamodel::ModuleHOW, Metamodel::PackageHOW |
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 delegate_methods_to #
method delegate_methods_to($type)
Delegates methods to $type. This should be a type object, but may be any object with a find_method metamethod technically.
method delegating_methods_to #
method delegating_methods_to()
Returns the type object a metaobject is delegating methods to.
method find_method #
method find_method($obj, $name)
Looks up a method on the type object this metaobject is delegating method dispatch to.
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 · 1 no-output · 1 not-runnable
role Metamodel::MethodDelegation { }Not executed: the documentation states no expected output for this example.
role Role { }
say Role.raku; # OUTPUT: «Role»
say Role.^pun.^parents(:all).map(*.^name); # OUTPUT: «()»Role
()
Role
(Any Mu)
Role
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.
say Role.HOW.delegating_methods_to.^name; # OUTPUT: «Any»
Neither engine can run this in isolation — the example depends on context from the surrounding text.