Take two hundred and seventy SIX -- you know this used to be fun??
Agree you could write, “Decides which of two operators appiled to the same operand is executed first.”Jesse Silverman wrote:. . . operator precedence The order in which operators are evaluated. . . .
What about reversing that expression?z = ++x * a - b;
I see what you mean, yes.. . . picks out all the highest precedence operations and completes them . . . left-to-right goes out the window . . .
I have never answered the same question more than a million times.. . . questions for the eighteen millionth time . . . .
Make all explanations as simple as possible, but not simpler.
Jesse Silverman wrote:operator precedence The order in which operators are evaluated.
Campbell Ritchie wrote:Agree you could write, “Decides which of two operators appiled to the same operand is executed first.”
Mike Simmons wrote:It's when you evaluate the operators where precedence and parentheses become important.
Stephan van Hulst wrote:Phrases like 'evaluation' and 'executed first' should never be mentioned in the same sentence as 'operator precedence', except when you say "Operator precedence has NOTHING to do with order of evaluation".
15.7. Evaluation Order
15.7.1. Evaluate Left-Hand Operand First
15.7.2. Evaluate Operands before Operation
15.7.3. Evaluation Respects Parentheses and Precedence
15.7.4. Argument Lists are Evaluated Left-to-Right
15.7.5. Evaluation Order for Other Expressions
JLS 15.7.3 wrote:15.7.3. Evaluation Respects Parentheses and Precedence
The Java programming language respects the order of evaluation indicated explicitly by parentheses and implicitly by operator precedence.
The entire point of operator precedence is determining which operands belong to which operators.
Stephan van Hulst wrote:The entire point of operator precedence is determining which operands belong to which operators.
Stephan van Hulst wrote:Operator precedence has NOTHING to do with order of evaluation
Operator precedence has NOTHING to do with order of evaluation of operands
Stephan van Hulst wrote:Notice that the entire paragraph has nothing to do with operator precedence, and only (erroneously) mentions operator precedence in the one sentence that you quoted. Even then, it is clear that is written as an offhand introductory text, and not as a technical definition.
Stephan van Hulst wrote:Operator precedence does not imply order of evaluation, explicitly or implicitly.
Stephan van Hulst wrote:The only thing that paragraph really says is that if an operator is mathematically associative, a Java implementation may not make use of that fact to rewrite expressions.
The operand evaluation is often trivial, so it's easy to overlook, but it's there, and it's always left-to-right...
I thought it has a section about, “evaluate operands before operators.”Paul Clapham wrote:. . . what it means to "evaluate" an operand. . . . spelling this out for beginners. . . . The JLS doesn't . . .
The JLS and API descrtibe different things with very little overlap; people should read both.Jesse Silverman wrote: . . . "Old" certification prep books . . . strongly recommended to consult the JLS early and often, and to not over-rely on just the Javadocs. . . .
My, those resources must be really badly written!. . . eminently readable compared to similar authoritative sources for say, C++ or SQL . . .
Don't now about that; I hope people still are reading the API and JLS as appropriate.. . . the community no longer expects the majority of people trying to work in Java to be regularly reading it. . . .
Which tutorials? Some I have seen are so bad, I wonder whether the providers have read anything.. . . for . . . a fair number who are providing the tutorial materials, the scope of RTFM does include the API docs, but includes reading the JLS less often than it did historically.
Thank you.. . . high levels of expert knowledge and an open, friendly attitude towards visitors . . . .
Campbell Ritchie wrote:
I thought it has a section about, “evaluate operands before operators.”Paul Clapham wrote:. . . what it means to "evaluate" an operand. . . . spelling this out for beginners. . . . The JLS doesn't . . .
Paul Clapham wrote:
Campbell Ritchie wrote:
I thought it has a section about, “evaluate operands before operators.”Paul Clapham wrote:. . . what it means to "evaluate" an operand. . . . spelling this out for beginners. . . . The JLS doesn't . . .
Well, yes, it does, but it focuses on situations where evaluation of an operand has side effects. It doesn't bring out Captain Obvious's Hammer.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |