Re: Power function as operator

From: Date: Fri, 22 Nov 2013 19:49:08 +0000
Subject: Re: Power function as operator
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-70290@lists.php.net to get a copy of this message
On 22/11/13 16:58, Tjerk Meesters wrote:
It introduces the pow() function as an operator ** (double asterisk), as can be found in languages such as Python (with perhaps the notable difference that it's right associative there).
This is great! I like Python's ** operator and having it in PHP would be great too. It's a very versatile mathematical operator. With ** you get three for the price of one: You can do powers ($x ** 2), you can do square roots ($x ** (1/2)) and you can do reciprocals ($x ** -1), though for that last one there was already 1 / $x. I will definitely vote for this proposal if it works and you make an RFC. I do have one concern, however. It looks like your current pull request doesn't make gmp support it. Nikita's (nikic) proposal to add internal operator overloading so that the gmp library could support it has been merged in. So could you make it overloadable (if it isn't already), and make sure gmp supports it? Thanks! -- Andrea Faulds http://ajf.me/

« previous php.internals (#70290) next »