Re: Power function as operator
| From: | Leigh | Date: | Fri, 22 Nov 2013 20:21:38 +0000 |
| Subject: | Re: Power function as operator | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70293@lists.php.net to get a copy of this message | ||
On 22 November 2013 17:08, Sherif Ramadan <theanomaly.is@gmail.com> wrote:
> I definitely like the idea of having pow as an operator. I've actually been
> wanting to copy that from Python for a while. I'm all for it.
On 22 November 2013 19:56, Sherif Ramadan <theanomaly.is@gmail.com> wrote:
> That looks very wrong. pow(pow(2,3),2) == 64
>
> Exponent precedence should always be one higher than multiplication
> precedence.
Where Tjerk has placed it is exactly as python has it. I think right
assoc is the correct choice here. If you imagine 2^3^2 written down,
you would do 2^(3^2), not (2^3)^2
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> 2 ** 3 ** 2
512