Re: Bug #1452 Updated: $i = $i++ fails
| From: | Zeev Suraski | Date: | Wed, 26 May 1999 00:56:58 +0000 |
| Subject: | Re: Bug #1452 Updated: $i = $i++ fails | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-6000@lists.php.net to get a copy of this message | ||
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.
Zeev
At 01:36 26/05/99 , Rasmus Lerdorf wrote:
In fact, if that loop hangs for you, than it succeeds doing what
it's supposed to do. $i=$i++ is equivalent to an empty statement.
Consult the documentation regarding what post-increment is to
understand why.
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.
Try this C program:
int main() {
int i=0;
while(i < 50) {
printf("%d\n",i);
i = i++;
}
}
It is the equivalent to his example and it correctly counts from 0 to 49,
so I do believe the submitter of this bug is correct.
-Rasmus
--
Zeev Suraski <zeev@zend.com> http://www.zend.com/
For a PGP public key, finger bourbon@netvision.net.il
--
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