develooper Front page | perl.perl5.porters | Postings from January 2001

Multiple post(inc|dec)rement

Thread Next
From:
Simon Cozens
Date:
January 15, 2001 01:31
Subject:
Multiple post(inc|dec)rement
Message ID:
20010115093106.A6525@pembro26.pmb.ox.ac.uk
I meant to copy this here from perl-friends, but, uh, missed.

----- Forwarded message from Simon Cozens <simon@cozens.net> -----
On Mon, Jan 15, 2001 at 09:16:22AM +0100, Johan Vromans wrote:
> But I still think that
>    perl -e '@a = (++$i,++$i,++$i); print "@a\n"'
> should print "1 2 3".

Oh, you should have said. :)

--- pp.c~	Mon Jan 15 08:59:54 2001
+++ pp.c	Mon Jan 15 09:13:47 2001
@@ -881,6 +881,7 @@
     else
 	sv_dec(TOPs);
     SvSETMAGIC(TOPs);
+    TOPs = sv_2mortal(newSVsv(TOPs));
     return NORMAL;
 }
 
--- pp_hot.c~	Mon Jan 15 09:00:35 2001
+++ pp_hot.c	Mon Jan 15 09:05:32 2001
@@ -314,6 +314,7 @@
     else /* Do all the PERL_PRESERVE_IVUV conditionals in sv_inc */
 	sv_inc(TOPs);
     SvSETMAGIC(TOPs);
+    TOPs = sv_2mortal(newSVsv(TOPs));
     return NORMAL;
 }
 
I'll leave adding tests until people have decided whether or not this
is appropriate/correct.

-- 
Putting a square peg into a round hole can be worthwhile if you don't mind a 
few shavings. -- Larry Wall

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About