Re: internals Digest 23 Nov 2013 00:01:03 -0000 Issue 3138
| From: | Walter Parker | Date: | Sat, 23 Nov 2013 01:47:46 +0000 |
| Subject: | Re: internals Digest 23 Nov 2013 00:01:03 -0000 Issue 3138 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70308@lists.php.net to get a copy of this message | ||
The Wikipedia page on Operator associativity, at
http://en.wikipedia.org/wiki/Operator_associativity,
says the
following:
Associativity is only needed when the operators in an expression have
the same precedence. Usually + and - have the same precedence.
Consider the expression 7 - 4 + 2. The result could be either (7 - 4)
+ 2 = 5 or 7 - (4 + 2) = 1. The former result corresponds to the case
when + and - are left-associative, the latter to when + and - are
right-associative.
In order to reflect normal mathematical usage, addition, subtraction,
multiplication, and division operators are usually left-associative
while an exponentiation operator (if present) is right-associative.
Any assignment operators are also typically right-associative. To
prevent cases where operands would be associated with two operators,
or no operator at all, operators with the same precedence must have
the same associativity.
Walter
---------- Forwarded message ----------
>
> From: Sherif Ramadan <theanomaly.is@gmail.com>
> To: Jakub Zelenka <bukka@php.net>
> Cc: Nikita Popov <nikita.ppv@gmail.com>, Tjerk Meesters <tjerk.meesters@gmail.com>,
> PHP Internals <internals@lists.php.net>
> Date: Fri, 22 Nov 2013 19:00:59 -0500
> Subject: Re: [PHP-DEV] Power function as operator
> On Fri, Nov 22, 2013 at 6:59 PM, Jakub Zelenka <bukka@php.net> wrote:
>
> > Hi,
> >
> >
> >> I'm not entirely sure that making it non-associative is a great idea
> >> either, but I have to agree that it does find *some* middle ground.
> >> Right-associative exponent operator didn't seem right to me either.
> >>
> >
> > I think there is a good mathematical reason for right associative
> > exponent. It calls tetration or power tower. Please look at following
> > sources for more details:
> >
> > http://math.stanford.edu/circle/notes08f/bignumbers.pdf
> > http://en.wikipedia.org/wiki/Tetration
> > http://mathworld.wolfram.com/PowerTower.html
> >
> > Regards
> >
> > Jakub
> >
>
>
> Right, that would be why I'm not *entirely* convinced.
>
--
The greatest dangers to liberty lurk in insidious encroachment by men
of zeal, well-meaning but without understanding. -- Justice Louis D.
Brandeis