Re: rfc: pow-operator
| From: | Nikita Popov | Date: | Sun, 24 Nov 2013 11:05:40 +0000 |
| Subject: | Re: rfc: pow-operator | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70350@lists.php.net to get a copy of this message | ||
On Sun, Nov 24, 2013 at 7:58 AM, Tjerk Meesters <tjerk.meesters@gmail.com>wrote:
> On Sun, Nov 24, 2013 at 8:31 AM, Kris Craig <kris.craig@gmail.com> wrote:
>
> > We should be following standard Order of Operations here. As such, the
> > option of no associativity should be included. Furthermore, there needs
> to
> > be a voting option regarding how to deal with even exponents of negative
> > bases; i.e. treat "-3 ^ 2" as "-3 ^ 2 == 9" or as "-(3 ^ 2) ==
> > -9".
> >
>
> To support the latter "-3 ** 2 == 9" we would require a unary minus that
> has a higher precedence than the exponent operator and as such falls
> outside of the scope of this RFC.
>
> That said, I'm not even sure whether we can support a unary minus with the
> current parser.
>
Huh? We already support a unary minus with the current parser. It has the
same precedence and associativity as ++ (%prec). You can adjust the
relative precedence of ** and - by adjusting the relative precedence of **
and T_INC (or making it completely independent if you like.)
Nikita