Re: Power function as operator

From: Date: Sat, 23 Nov 2013 05:35:40 +0000
Subject: Re: Power function as operator
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-70315@lists.php.net to get a copy of this message
Hi Andrea, On Sat, Nov 23, 2013 at 3:49 AM, Andrea Faulds <ajf@ajf.me> wrote: > > > 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? > Sure, gmp has gmp_pow(), so I don't think it will be a huge problem to support this :) > > Thanks! > -- > Andrea Faulds > http://ajf.me/ > -- -- Tjerk

« previous php.internals (#70315) next »