From: Jan Dubois Date: Thu, 25 May 2006 18:20:25 +0000 (-0700) Subject: RE: perlhack.pod confused about POPSTACK X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e89a6d4ec25220634f772b600b8e9c56f45d9de2;p=p5sagit%2Fp5-mst-13.2.git RE: perlhack.pod confused about POPSTACK From: "Jan Dubois" Message-Id: <059101c68062$9143d550$2217a8c0@candy> more fixing of the PUSHMARK example p4raw-id: //depot/perl@28317 --- diff --git a/pod/perlhack.pod b/pod/perlhack.pod index fc3c686..43e76ac 100644 --- a/pod/perlhack.pod +++ b/pod/perlhack.pod @@ -1356,10 +1356,6 @@ roughly how the tied C is implemented; see C in F: 7 call_method("PUSH", G_SCALAR|G_DISCARD); 8 LEAVE; -The lines which concern the mark stack are the first, fifth and last -lines: they save away, restore and remove the current position of the -argument stack. - Let's examine the whole implementation, for practice: 1 PUSHMARK(SP); @@ -1379,8 +1375,8 @@ retrieved with C, and the value, the SV C. 5 PUTBACK; -Next we tell Perl to make the change to the global stack pointer: C -only gave us a local copy, not a reference to the global. +Next we tell Perl to update the global stack pointer from our internal +variable: C only gave us a local copy, not a reference to the global. 6 ENTER; 7 call_method("PUSH", G_SCALAR|G_DISCARD); @@ -1394,7 +1390,9 @@ C<}> of a Perl block. To actually do the magic method call, we have to call a subroutine in Perl space: C takes care of that, and it's described in L. We call the C method in scalar context, and we're -going to discard its return value. +going to discard its return value. The call_method() function +removes the top element of the mark stack, so there is nothing for +the caller to clean up. =item Save stack