In Variables§
See primary documentation in context for &?ROUTINE
The compile time variable &?ROUTINE
provides introspection about which routine the program is actually within. It returns an instance of Routine attached to the current routine. It does support the method .name
to obtain the name of the called routine, as well as .signature
and others method related to Routine
:
sub awesome-subawesome-sub; # OUTPUT: «awesome-sub»
It also allows also for recursion:
my = 10;sub do-workdo-work;
Note that, in a multi
, &?ROUTINE
refers to the current candidate, not the multi
as a whole.
Thus, the following recursive definition does not work:
multi broken-fibonacci( where * ≤ 1)multi broken-fibonacci( where * > 0)
If called, &?ROUTINE
would always refer to the second multi candidate and would never dispatch to the first. If you want to use self-recursion for the whole proto
, either use the function name or samewith
.