The current status of D?

Timon Gehr timon.gehr at gmx.ch
Wed Dec 7 00:16:05 PST 2011


On 12/07/2011 08:35 AM, Kagamin wrote:
>>> int z = 0;
>>> int foo(int x, int y) { return x + y; }
>>> int bar(int x) { z++; return x * x + z; }
>>> int baz(int x) { z--; return 2 * x + z; }
>>> int main() {
>>> int w = foo(bar(5), baz(3));
>>> return w;
>>> }
>>> See also:
>>> http://en.wikipedia.org/wiki/Sequence_point
>> I think ',' in parameter lists are already sequence points.
> They aren't, but a function call is a sequence point, so bar is
> guaranteed to be called before baz.

?

If bar is guaranteed to be called before baz, then the ',' is associated 
with a sequence point. You are right that there is a sequence point 
before a function call, but that only guarantees that bar and baz are 
called before foo, and says nothing about the evaluation order of bar 
and baz (note that function calls are sequence points in C/C++, but the 
order of argument evaluation is unspecified).


More information about the Digitalmars-d mailing list