Skip to content

Commit

Permalink
adding docs and an example for nextcallee
Browse files Browse the repository at this point in the history
  • Loading branch information
zostay committed Jul 19, 2016
1 parent b0666ad commit 2761ecd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Language/functions.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,20 @@ class LoggedVersion is Version {
say LoggedVersion.new('1.0.2');
=end code
If you need to make multiple calls to the wrapped code or to gain a reference to
it, such as for performing introspection on the it, you can use C<nextcallee>.
=begin code
sub power-it($x) { $x * $x }
sub run-it-again-and-again($x) {
my &again = nextcallee;
again again $x;
}
&power-it.wrap(&run-it-again-and-again);
say power-it(5); # 625
=end code
=head1 Coercion Types
Coercion types can help you to have a specific type inside a routine, but
Expand Down

0 comments on commit 2761ecd

Please sign in to comment.