From: Mike Schilling on
Lew wrote:
> Mike Schilling wrote:
>> Lew wrote:
>>
>>> However, the JLS does refer to 'instanceof' as an
>>> operator.
>>
>> But it's not in the list of operators, so the JLS contradicts
>> itself.
>> It really is the Java programmer's Bible!
>>
>> More seriously, the official JLS definition of "operator" describes
>> only operators made up of special characters; that is, it
>> distinguishes "operator" from "keyword".
>
> I was just going by
> <http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.20.2>
> entitled "Type Comparison Operator instanceof". That looks an awful
> lot like an "official JLS definition" to me.

Sorry, I meant that 15.20.2 disagrees with the list in 3.12. Which is
fine; it's not as if giving a precise defintions of "operator" is one
of the JLS's most important goals.

This reminds me of a discussion that went on in comp.lang.c years ago.
Someone was asking whether "3 + 12i" was an imaginary number or not.
He'd seen some references that said "3 + 12i" was imaginary but not
"pure imaginary", and others that said "3 + 12i" was not imaginary
because it had a real part. He wanted to know the answer, because,
dammit, in mathematics there's always one right answer. No one could
convince him otherwise.


From: Patricia Shanahan on
Robbo wrote:
....
> 1. According to some resources, postfix and prefix
> have the same level (precedence). It is right?
....

++(a--) and (++a)-- both apply an operator requiring a variable to a
non-variable value. ++a-- is an error.

Patricia
From: Lew on
Mike Schilling wrote:
> This reminds me of a discussion that went on in comp.lang.c years ago.
> Someone was asking whether "3 + 12i" was an imaginary number or not.
> He'd seen some references that said "3 + 12i" was imaginary but not
> "pure imaginary", and others that said "3 + 12i" was not imaginary
> because it had a real part. He wanted to know the answer, because,
> dammit, in mathematics there's always one right answer. No one could
> convince him otherwise.

That was a much more complex question, though.

--
Lew
From: Robbo on
> Actually, UnaryExpressionNotPlusMinus contains CastExpression, so it is
> actually at the same precedence level as logical and bitwise NOT, which
> is one higher than the prefix/unary +/unary - (UnaryExpression contains
> PreIncrementExpression, PreDecrementExpression, and the unary +/unary -).


UnaryExpressionNotPlusMinus contains PostFixExpression also.

To be honest, I do not understand Your sentence above.
Does it mean that "cast" is at the same level as ~ and ! but
there should be one more level (above ~ ! and cast)
with unary +/-/--expr/++expr?

1. expr++, expr--
2. ++expr, --expr, +expr, -expr
3. ~ ! (type)


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

Ok. Thx.


Level Category Operator Associativity
---------------------------------------------------------------
1 postfix expr++ expr-- +
---------------------------------------------------------------
2 prefix ++expr --expr right+
unary +expr -expr
logical NOT !
bitwise NOT ~
---------------------------------------------------------------
3 cast (type) right+
---------------------------------------------------------------
4 multiplicative * / % left+
---------------------------------------------------------------
5 additive + - left+
---------------------------------------------------------------
6 shift << >> >>> left+
---------------------------------------------------------------
7 relational < <= > >= left+
type comparison instanceof
---------------------------------------------------------------
8 equality == != left+
---------------------------------------------------------------
9 bitwise AND & left+
---------------------------------------------------------------
10 bitwise XOR ^ left+
---------------------------------------------------------------
11 bitwise OR | left+
---------------------------------------------------------------
12 logical AND && left+
---------------------------------------------------------------
13 logical OR || left+
---------------------------------------------------------------
14 conditional ?: right+
---------------------------------------------------------------
15 assignment = += -= *= /= right+
%= &= ^= |=
<<= >>= >>>=
---------------------------------------------------------------



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