Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #547 from zostay/nextcallee
adding docs and an example for nextcallee
  • Loading branch information
jonathanstowe committed Jul 19, 2016
2 parents 5c26823 + 6530643 commit 5dc3a7d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Language/functions.pod6
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 performing introspection 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 5dc3a7d

Please sign in to comment.