Re: Operator precedence is undefined?
| From: | Sara Golemon | Date: | Sat, 20 Jul 2013 00:36:15 +0000 |
| Subject: | Re: Operator precedence is undefined? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68231@lists.php.net to get a copy of this message | ||
If run right now, it will always produce the same value (4), but it isn't
*defined* to do so. What that means is that behavior is subject to change
without notice, warning, or justification. This is a somewhat harsh way of
saying "Don't write expressions with ambiguous evaluations, that's clowny."
I would ask that you don't "fix" the docs, as we want to continue to
discourage users from engaging in unsafe behaviors.
On Fri, Jul 19, 2013 at 5:12 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> Hi all,
>
> Take a look at this bug report.
>
> https://bugs.php.net/bug.php?id=65087
>
> He complains about documentation of ++/--.
> The doc says
>
> http://www.php.net/manual/en/language.operators.precedence.php
> ---------------
> // mixing ++ and + produces undefined behavior
> $a = 1;
> echo ++$a + $a++; // may print 4 or 5
> ---------------
>
> "may print 4 or 5"?? Undefined??
> In old PHP there may be such limitation.
>
> I cannot believe this is true now, but I ask list before I fix doc.
>
> Any comments?
>
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net
>