[3917] in java-interest
Re: Order of evaluation and determinism
daemon@ATHENA.MIT.EDU (Ken Arnold - Sun Labs)
Sat Dec 2 04:33:30 1995
Date: Thu, 30 Nov 1995 16:54:24 -0500
From: arnold@cocolat.East.Sun.COM (Ken Arnold - Sun Labs)
To: java-interest@webrunner.neato.org
>Anyway, I'm wondering about the case of order of evaluation of
>expressions and the effects of their side-effects. Does Java have a
>notion similar to C's "sequence points", and the corresponding
>limitations of modifying a variable twice between them?
Java guarantees left-to-right order of evaluation. Simple, no? So
i = 12;
x = foo(i++) + bar(i++);
means that foo() gets passed twelve, i is incremented to 13, and then
foo() is executed (thus, if i was accessible inside foo(), foo() would
see i with the value 13). After foo() returns, then bar() is passed
13, and then after bar() returns, the values are added together, and
then x is set to the sum.
Ken
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com