[...]
> Section 15.15 Unary Operators in the JLS does not mention
> "associativity" but just says "Expressions with unary operators group
[quoted text clipped - 3 lines]
> That rule allows stacking of unary operators without requiring
> parentheses.
Thanks for this pointer! Can I conclude that unary operators in Java
have *no* associativity but just a right-to-left "grouping"?
> Is there some other place you are thinking of, that does talk about
> associativity for unary operators? Could you give a reference?
Yes. I came across this in Table 5.3 (Page 241) of the book _An
Introduction to Object-Oriented Programming with Java_ by C. Thomas Wu
(4 Ed).
Also, most online Java references which have an operator precedence
table slap a right-to-left "associativity" on the unary operators. For
example:
<http://www.cs.uwf.edu/~eelsheik/cop2253/resources/op_precedence.html>
Thanks,
~ash

Signature
Ashwin Nanjappa
http://ashwin.zaatar.org/
Patricia Shanahan - 09 Sep 2006 13:41 GMT
> [...]
>> Section 15.15 Unary Operators in the JLS does not mention
[quoted text clipped - 7 lines]
> Thanks for this pointer! Can I conclude that unary operators in Java
> have *no* associativity but just a right-to-left "grouping"?
I was cautious about saying that, because I don't have the entire JLS
memorized.
The JLS does use the term "associative", but in its mathematical sense,
as the property that, for a binary operation "op", "(a op b) op c" is
equal to "a op (b op c)".
For example, "Addition is a commutative operation if the operand
expressions have no side effects. Integer addition is associative when
the operands are all of the same type, but floating-point addition is
not associative." in 15.18.2 Additive Operators (+ and -) for Numeric Types.
>> Is there some other place you are thinking of, that does talk about
>> associativity for unary operators? Could you give a reference?
[quoted text clipped - 7 lines]
> example:
> <http://www.cs.uwf.edu/~eelsheik/cop2253/resources/op_precedence.html>
Perhaps try writing to the author of one of those sources asking what
they mean by "associativity" when applied to unary operators? Even for
binary operations, the on-line reference seems to be using
"associativity" as somehow relating to order of evaluation, rather than
as meaning that order of evaluation does not matter.
Patricia