note 97872 deleted from language.operators.increment by danbrown
| From: | danbrown@php.net | Date: | Thu, 13 May 2010 13:44:37 +0000 |
| Subject: | note 97872 deleted from language.operators.increment by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169214@lists.php.net to get a copy of this message | ||
Note Submitter: Ezekiel Victor
----
Knowing nothing about how PHP implements these operators, it appears to me that dsbeam's tests
below yield a logical result. After all, in order for the post-increment/post-decrement operators to
return the initial value *before* the operation occurs, I would think the operators must use a small
amount of memory to store the initial value before performing the operation. Otherwise, the initial
value wouldn't be available to return after the operation.
Here's a pseudo code example of how pre- and post-increment operators might be implemented:
operator ++() // pre-increment
increment value
return value
operator ++(int) // post-increment
store value
increment value
return stored value from before increment