Velocity Reviews > Java > Re: Looking for good table with all Java operators

# Re: Looking for good table with all Java operators

Lew
Guest
Posts: n/a

 01-26-2010
Robbo wrote:
> Level Category Operator Associativity
> ---------------------------------------------------------------
> 1 postfix expr++ expr-- left

As I was corrected upthread (perhaps you missed that post), there is no
associativity for postfix operators.

--
Lew

Lew
Guest
Posts: n/a

 01-26-2010
Lew wrote:
>> As I was corrected upthread (perhaps you missed that post), there is no
>> associativity for postfix operators.

Robbo wrote:
> Ok. Thx.
>
>
> Level Category Operator Associativity
> ---------------------------------------------------------------
> 1 postfix expr++ expr-- +
> ---------------------------------------------------------------
> 2 prefix ++expr --expr right+

The same reasoning applies to prefix auto{in,de}crement.

It's been pointed out before, although to be fair, to reach the conclusion it
would have required thinking about what Patricia posted.
> ++(a--) and (++a)-- both apply an operator
> requiring a variable to a non-variable value.

There's no point talking about associativity of prefix ++ if ++++x is an
illegal expression. (Or if it means that unary + is applied twice to ++x - I
didn't try it. Why don't you? It'll be a fun experiment.)

Thinking about things is a fundamental tool in the programmer's toolbox.

--
Lew

Tom Anderson
Guest
Posts: n/a

 01-26-2010
On Tue, 26 Jan 2010, Thomas Pornin wrote:

> According to Lew <(E-Mail Removed)>:
>> There's no point talking about associativity of prefix ++ if ++++x is an
>> illegal expression.

>
> There is no "associativity" at all for unary operators. Associativity is
> a notion which is defined only for binary operators.

True. The equivalent for unary operators is probably distributivity, or
whatever it's called. Like how -(a+b) == (-a)+(-b). Although of course
-(a*b) != (-a)*(-b), so it's a bit more complicated. And not at all
related to drawing up tables of operators.

tom

--
hypnopomp rapist