Re: Re: [vote] pow-operator

From: Date: Thu, 19 Dec 2013 18:08:44 +0000
Subject: Re: Re: [vote] pow-operator
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


On 19/12/13 02:38, Levi Morrison wrote:
That said, if there are other reasons for voting 'no' besides associativity, feel free to shoot me an email or discuss it on the list.
What did it for me was the lower precedence for the unary minus. I don't want to have another language that thinks a negative number squared is a negative number. I understand and respect your reasoning as outlined in the RFC, but this is a deal-breaker for me.
I've had a short discussion with Anthony about this and he convinced me that I was indeed wrong about my "unary minus" reasoning; therefore I have updated the RFC to reflect that. So: echo -3 ** 2; // 9 echo 1 - 3 ** 2; // -8 The unary minus is now at the same level as [, the array dereferencing operator.
We should follow the mathematic precedence rules; -3 ** 2 should be -9. Note that "-3^2" as input to Mathematica, Matlab and Google search engine all gave -9 as the answer, *as mathematically expected*.
It would be quite strange if we treated "0 - 3 ^ 2" and "- 3 ^ 2" differently. They should be identical! -- Andrea Faulds http://ajf.me/

Thread (15 messages)

« previous php.internals (#70753) next »