Re: Operator precedence is undefined?

From: Date: Sat, 20 Jul 2013 06:25:28 +0000
Subject: Re: Operator precedence is undefined?
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Sara,

2013/7/20 Sara Golemon <[email protected]>
>
> What's undefined isn't the relationship between preinc/postinc and add.
 What's undefined is the use of multiple preinc/postinc operators within a
single expression (preincrements in particular).  Our parser grammer, as it
currently stands, does have a predictable order, but that is a side-effect
of implementation.  The language's definition of order of resolution of
multiple preinc/postinc elements within a single ticked statement is that
they are undefined.  And *that* is what made your *particular* change to
the documentation incorrect.
>
> If you'd like to define behavior for:  echo ++$a + 1;  then that's a
different matter.  Defining the behavior of ++$a + $a++, however is
inviting misunderstanding*.
>
> What was inappropriate, was asking for comment, receiving comment which
cited an issue, then committing without discussing that issue first.
>
> -Sara
>
> * Even if, technically, either order of evaluation will result in the
same answer for this contrived expression.  ++$a * $a++ is a more obviously
ambiguous answer for a language which explicitly does not define an order
of resolution.

++/-- can be problematic for compilers when it is applied to in the same
arithmetic operator.
I can agree with this. It depends on compiler implementation.

I understand you suggesting users are suggested not to use -- ++ for the
same vars on the same arithmetic operations.

Is this correct?

Regards,

--
Yasuo Ohgaki
[email protected]


Thread (30 messages)

« previous php.internals (#68258) next »