From: Simon Cozens Date: Mon, 26 Feb 2001 12:23:48 +0000 (+0000) Subject: XPUSH[insp] was Re: progress X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1bd1c0d55f7ef526804dc7dc113e1957e1b2b423;p=p5sagit%2Fp5-mst-13.2.git XPUSH[insp] was Re: progress Message-ID: <20010226122348.A25536@pembro26.pmb.ox.ac.uk> p4raw-id: //depot/perl@8952 --- diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 557dbaf..35741c6 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 to extend the stack. +However, see L For more information, consult L and L. @@ -1384,6 +1385,23 @@ The macro to put this target on stack is C, 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 to 10, push a pointer to C onto +the stack; set C to 20, push a pointer to C 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, which we have set +to 20. If you need to push multiple different values, use C, +which bypasses C. + +On a related note, if you do use C<(X)PUSH[npi]>, then you're going to +need a C in your variable declarations so that the C<*PUSH*> +macros can make use of the local variable C. + =head2 Scratchpads The question remains on when the SVs which are Is for opcodes