hi,

I was browsing the TODO list for some low hanging fruit, and saw a request for updating PDD20.

Attached a patch that adds a description of get_outer() according to t/op/lexicals.t to PDD20.

regards,
klaas-jan
Index: docs/pdds/pdd20_lexical_vars.pod
===================================================================
--- docs/pdds/pdd20_lexical_vars.pod	(revision 17016)
+++ docs/pdds/pdd20_lexical_vars.pod	(working copy)
@@ -80,7 +80,7 @@
 Parrot runtime stores and fetches lexical variables.
 
 At run time, each call frame for a Subroutine (or Subroutine derivative) that
-uses lexical variables will be populated with a PMC of HLL-mapped 
+uses lexical variables will be populated with a PMC of HLL-mapped
 type LexPad.  Note that call frames for subroutines without lexical
 variables will omit the LexPad.
 
@@ -341,11 +341,41 @@
     $P0 = getinterp
     $P1 = $P0["lexpad"; 1]
 
+To access a sub's C<:outer> subroutine, use the C<get_outer()> method:
+
+    .include "interpinfo.pasm"
+    interpinfo $P1, .INTERPINFO_CURRENT_SUB
+    $P2 = $P1."get_outer"()
+
+Here, C<$P1> contains information on the current subroutine. C<$P2> will
+contain C<$P1>'s outer subroutine.
+
+To get C<$P2>'s outer subroutine (if any), the same method can be used on C<$P2>
+itself:
+
+    $P3 = $P2."get_outer"()
+
+
+Using the C<interpinfo> instruction is one way to do it. Another way is this:
+
+    $P0 = getinterp
+    $P1 = $P0["outer"; "sub"]
+    $P2 = $P0["outer"; "sub"; 2] # get the outer sub of the current's outer subroutine
+
+It is also possible to get the C<:outer> sub's LexPad, as above:
+
+    $P0 = getinterp
+    $P1 = $P0["outer"; "lexpad"]
+
+See [1] for an example.
+
 It's likely that this interface will continue to be available even once call
 frames become visible as PMCs.
 
+
 TODO: Full interpreter introspection interface.
 
+
 =head1 ATTACHMENTS
 
 None.
@@ -356,8 +386,14 @@
 
 =head1 REFERENCES
 
-None.
+=over 4
 
+=item [1]
+
+t/op/lexicals.t
+
+=back
+
 =cut
 
 __END__

Reply via email to