Re: Bug #1452 Updated: $i = $i++ fails

From: Date: Wed, 26 May 1999 00:54:26 +0000
Subject: Re: Bug #1452 Updated: $i = $i++ fails
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-6003@lists.php.net to get a copy of this message
Rasmus wrote: >> Uh? >> >> $i = $i++; >> >> This should be equivalent to doing: >> >> $i=$i; >> $i++; >> >> at least from my understanding of what post-increment is supposed to do. Zeev Suraski replied: > Not really. In fact, in C, it's undefined. In PHP, it's always nada. > > A C compiler can understand it as: > result = rvalue > inc(rvalue) > lvalue = result > > or > > lvalue = rvalue > inc(rvalue) > > Compilers generally do it the first way and not the second way, even > though they can choose either. It's undefined which part of an > assignment expression is evaluated first. I'm afraid I have to agree with Rasmus here. Laying aside the fact that it's undefined in C and a silly thing to do in the first place, is there any reason for PHP to adopt the former case rather than the later? Conceptually, $i = $i++ should work even if it is redundant. Clearly it's not worth spending a lot of time on, but if it's a simple fix, why not? --------------------------------------------------------- Colin Putney colin@whistler.net Bit Flinger (604) 932-0606 x21 Whistler Networks http://www.whistler.net/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#6003) next »