Re: Re: rfc: pow-operator

From: Date: Sun, 24 Nov 2013 20:58:24 +0000
Subject: Re: Re: rfc: pow-operator
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-70359@lists.php.net to get a copy of this message
> On Nov 24, 2013, at 8:57, "Pierre Joye" <pierre.php@gmail.com> wrote: > > it not be possible to do something similar than isset? Changing > pow from a function to operator? The big advantage is that any > existing code will benefit from it without code changes. Personally, I'd much rather see another operator introduced since it more closely mirrors what we do in written math, which makes conversion and validation easier. Some simple examples: $area = M_PI * $radius**2 Instead of this: $area = pow(M_PI * $radius, 2) $pv = $fv / (1 + $i)**$n Instead of this: $pv = $fv / pow(1 + $i, $n) $c = sqrt($c1**2 + $c2**2) Instead of this: $c = sqrt(pow($c1, 2) + pow($c2, 2)) When you start throwing in nested exponents, the nested pow() calls just get that much messier. As for existing code (and new code where people will inevitably use pow()), can the function call be optimized away? I know PHP doesn't do heavy optimizations because it happens at runtime, but is this conversion within the realm of what it can do? -- Bob Williams Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or if you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any).

« previous php.internals (#70359) next »