From: Eric Sosman on
On 1/25/2010 3:31 PM, Robbo wrote:
> [...]
> And in (byte)x++, (byte) is first because of higher priority of cast
> than postfix ++.
> What do you think?

Even without checking the JLS, it's easy to see that
this is wrong. If the cast had higher precedence, the
expression would be equivalent to

( (byte)x )++

.... which is nonsense. Consider a wider context like

double x = 42.0;
( (byte)x )++;

.... and ponder: "What primitive does the ++ operator modify?"

Therefore: If the cast has higher precedence the compiler
must reject the expression, so if the compiler accepts it the
cast does not have higher precedence.

--
Eric Sosman
esosman(a)ieee-dot-org.invalid
From: Tom Anderson on
On Tue, 26 Jan 2010, Thomas Pornin wrote:

> According to Lew <noone(a)lewscanon.com>:
>> 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
From: Robbo on

U�ytkownik "Thomas Pornin" <pornin(a)bolet.org> napisa� w wiadomo�ci
news:4b5f0217$0$29839$426a74cc(a)news.free.fr...
> According to Lew <noone(a)lewscanon.com>:
> > 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.


JLS 3d edition, point 15.15 Unary operators:

"The unary operators include +, -, ++, --, ~, !, and cast operators.
Expressions with unary operators group right-to-left, so that -~x
means the same as -(~x)."



First  |  Prev  | 
Pages: 1 2 3 4 5 6 7 8
Prev: ?k???O?T?h???C
Next: JVM and java application