Skip to content

Commit

Permalink
Modifies example to make it work
Browse files Browse the repository at this point in the history
Closes #1554
  • Loading branch information
JJ committed Apr 7, 2018
1 parent 08f5d74 commit 7701840
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions doc/Type/CallFrame.pod6
Expand Up @@ -22,20 +22,24 @@ Each frame stores L<annotations>, including the L<file> and L<line> annotations,
Here's a short example that will find the calling routine and prints the package of the caller using the C<callframe> interface.
for 1..* -> $level {
given callframe($level) -> $frame {
when $frame ~~ CallFrame {
next unless $frame.code ~~ Routine;
say $frame.code.package;
last;
}
default {
say "no calling routine or method found";
last;
sub calling-frame() {
for 1..* -> $level {
given callframe($level) -> $frame {
when $frame ~~ CallFrame {
next unless $frame.code ~~ Routine;
say $frame.code.package;
last;
}
default {
say "no calling routine or method found";
last;
}
}
}
}
calling-frame;
If you just need to trace caller information, L<Backtrace> may provide a better means of getting information. L<CallFrame> contains more information about a specific frame, but provides a tedious interface for enumerating a call stack.
=head1 Methods
Expand Down

0 comments on commit 7701840

Please sign in to comment.