best replacement for - cout << "hello D" << endl; ?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Jul 11 07:25:27 PDT 2007


Manfred Nowak wrote:
> Additional remark:
> The cuurent semantics of chaining relies on an existing but unspecified 
> evaluation order. This might turn out to be a shot in the leg according 
> to the specs:
> | It is an error to depend on order of evaluation when it is not
> | specified.

As has been posted on these newsgroups before (including, IIRC, by 
Walter) order of evaluation when using chaining is not a problem unless 
calculating the extra values has side-effects. For example, in
---
Stdout("a")(1)("b");
---
the values of "a", 1 and "b" may be determined in any order, but they 
will be passed to the output in the order they appear. The code that 
gets executed is equivalent to
---
foo(foo(foo(Stdout, "a"), 1), "b");
---
where each inner foo must be executed before execution of an outer one 
can start because the inner foo returns a value used as a parameter of 
the outer foo (the 'this' value of opCall).

In other words: it's *not* an error to depend on order of evaluation 
when it *is* specified. :)


More information about the Digitalmars-d-learn mailing list