class Routine
src
class Routine is Block { }
A Routine is a code object meant for larger unities of code than L<Block>.
Routine is the common superclass for L<Sub> and L<Method>, the two primary
code objects for code reuse.
Routines serve as a scope limiter for return (ie a return returns
from the innermost outer Routine).
Routine is also the level at which multiness (multi subs and multi methods)
are handled.
Methods
multi
method multi(Routine:D:) returns Bool:D
Returns True if the routine is a multi sub or method.
candidates
method candidates(Routine:D:) returns Positional:D
Returns a list of multi candidates, or a one-element list with itself
if it's not a multi
wrap
method wrap(Routine:D: &wrapper)
Wraps (ie in-place modifies) the routine. That means a call to this routine
first calls &wrapper , which then can (but doesn't have to) call the
original routine with the callsame , callwith , nextsame and
nextwith dispatchers. The return value from the routine is also
the return value from the wrapper.
wrap returns a wrap handler, which you can pass to L<unwrap> to restore
the original routine.
unwrap
method unwrap(Routine:D: $wraphandler)
Restores the original routine after it has been wrapped with L<wrap>.
yada
method yada(Routine:D:) returns Bool:D
Returns True if the routine is a stub
say (sub f() { ... }).yada # True
say (sub g() { 1; }).yada # False