summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorSimon Cozens <simon@netthink.co.uk>2001-02-26 12:23:48 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-02-26 14:42:13 +0000
commit1bd1c0d55f7ef526804dc7dc113e1957e1b2b423 (patch)
treeaa21b5c9ff5703ffd4f16ad87a31d61884a57aed /pod
parenta0ea11f27510bfd5c321cc9b6bbb1b1dc64a058c (diff)
downloadperl-1bd1c0d55f7ef526804dc7dc113e1957e1b2b423.tar.gz
XPUSH[insp] was Re: progress
Message-ID: <20010226122348.A25536@pembro26.pmb.ox.ac.uk> p4raw-id: //depot/perl@8952
Diffstat (limited to 'pod')
-rw-r--r--pod/perlguts.pod18
1 files changed, 18 insertions, 0 deletions
diff --git a/pod/perlguts.pod b/pod/perlguts.pod
index 557dbaf306..35741c6225 100644
--- a/pod/perlguts.pod
+++ b/pod/perlguts.pod
@@ -1255,6 +1255,7 @@ to use the macros:
These macros automatically adjust the stack for you, if needed. Thus, you
do not need to call C<EXTEND> to extend the stack.
+However, see L</Putting a C value on Perl stack>
For more information, consult L<perlxs> and L<perlxstut>.
@@ -1384,6 +1385,23 @@ The macro to put this target on stack is C<PUSHTARG>, and it is
directly used in some opcodes, as well as indirectly in zillions of
others, which use it via C<(X)PUSH[pni]>.
+Because the target is reused, you must be careful when pushing multiple
+values on the stack. The following code will not do what you think:
+
+ XPUSHi(10);
+ XPUSHi(20);
+
+This translates as "set C<TARG> to 10, push a pointer to C<TARG> onto
+the stack; set C<TARG> to 20, push a pointer to C<TARG> onto the stack".
+At the end of the operation, the stack does not contain the values 10
+and 20, but actually contains two pointers to C<TARG>, which we have set
+to 20. If you need to push multiple different values, use C<XPUSHs>,
+which bypasses C<TARG>.
+
+On a related note, if you do use C<(X)PUSH[npi]>, then you're going to
+need a C<dTARG> in your variable declarations so that the C<*PUSH*>
+macros can make use of the local variable C<TARG>.
+
=head2 Scratchpads
The question remains on when the SVs which are I<target>s for opcodes