sub lastcall
Documentation for sub lastcall
assembled from the following types:
class Method
From Method
(Method) sub lastcall
sub lastcall(--> True)
Truncates the current dispatch chain, which means any calls to nextsame
, callsame
, nextwith
, and callwith
will not find any of the next candidates. Note that since samewith
restarts the dispatch from the start, it's not affected by the truncation of current chain with lastcall
.
Consider example below. foo(6)
uses nextsame
when lastcall
hasn't been called, and so it reaches the Any
candidate. foo(2)
calls nextsame
as well, but since lastcall
was called first, the dispatch chain was truncated and the Any
candidate was not reached. The last call, foo(1)
, calls lastcall
too, however, it then uses samewith
, which isn't affected by it, and so the dispatch re-starts from scratch, hits the Int
candidate with the new argument 6
, and then proceeds to the Any
candidate via nextsame
(which isn't affected by the lastcall
that was used before the samewith
was called):
multi foo (Int )multi foo (Any )foo 6; say '----';foo 2; say '----';foo 1;# OUTPUT:# Int: 6# Any 6# ----# Int: 2# ----# Int: 1# Int: 6# Any 6