@@ -167,15 +167,28 @@ L<here|/language/control#proceed_and_succeed>.
167
167
168
168
= item caller EXPR
169
169
170
- [NEEDS FURTHER RESEARCH] What C < caller > does in Perl 5 is taken on by
171
- C < callframe > . However, a simple call to C < callframe > will be of little
172
- use, as it will return a CallFrame object, rather than any useful
173
- information. The filename and line number returned as the second and
174
- third values from C < caller > in Perl 5, are in C < callframe.annotations > .
175
- You get them by using C << callframe().annotations.<file line> >> or,
176
- individually, with C << callframe().annotations.<file> >> and C <<
177
- callframe().annotations.<line> >> . There does not seem to be a simple
178
- way of getting the package name out of C < callframe > however.
170
+ There are a couple different ways to get at caller information in Perl 6.
171
+ The basic functionality is provided through L < callframe > now. However, Perl 6
172
+ constructs call frames for regular blocks, not just for subroutines, so there
173
+ are more frames to look through. The following will retrieve the basic
174
+ information that C < caller > can return:
175
+
176
+ my $frame = callframe(0); # OR just callframe()
177
+ my ($subroutine, $package);
178
+ if $frame.code ~~ Routine {
179
+ $subroutine = $frame.code.name;
180
+ $package = $frame.code.package;
181
+ }
182
+ my $file = $frame.file;
183
+ my $line = $frame.line;
184
+
185
+ Many of the other details returned by C < caller > are specific to Perl 5 and have
186
+ no meaning in Perl 6.
187
+
188
+ You can also get some of the information for the current frame or routine frame
189
+ by using the dynamic variables L < &?ROUTINE > , L < &?BLOCK > , L < $?PACKAGE > ,
190
+ L < $?FILE > , and L < $?LINE > . For many purposes, L < Backtrace > may provide an easier
191
+ way to browse through the call stack.
179
192
180
193
= head2 chdir
181
194
0 commit comments