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

From: Date: Wed, 26 May 1999 01:49:43 +0000
Subject: Re: Bug #1452 Updated: $i = $i++ fails
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-6005@lists.php.net to get a copy of this message
Rasmus Lerdorf wrote: >> 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? > > Well, I am not sure I agree with me. I was more suggesting that the > original person was not completely out to lunch as Zeev originally made it > sound. I have no problems leaving the current PHP behaviour be. I guess I should have been a little more clear about what I was agreeing with. The original bug report stated that PHP behaved differently than C. Zeev pointed out that this is not the case, as C's behaviour is undefined, whereas PHP at least behaves consistently. Fair enough. Your comment brought up the point that, to a programmer, $i = $i++ has a well defined meaning: $i = $i; $i = $i + 1; Presumably, C doesn't define the order which assigment operands are evaluated for a reason - to allow the compiler some flexibility in optimizing for a particular architecture. Well and good. But PHP only has one implementation, and you guys can define both the semantics of the language and the behaviour of the interpreter (or compiler as with Zend) however you want. My question was not entirely rhetorical. Is there a reason to choose the current behaviour (which is counter-intuitive and can lead to bugs in programs which are not well written) over the alternative (where PHP behaves as expected)? There may well be. Performance or cleanness of implementation are excellent reasons. If it were a lot of work to change, that would be a good reason. I don't have enough experience to judge. But if it makes no difference, why not make PHP that little bit more robust, even in goofy cases like this? cp --------------------------------------------------------- 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 (#6005) next »