On Monday, 18 June 2012 at 15:13:33 UTC, deadalnix wrote:
Identical calls giving identical results? What?


import std.stdio;
struct S
{
this(int a)
{
this.a = a;
this.increment = { return this.a++; };
}
int a;
int delegate() pure increment;
auto oops() const { return this.increment(); }
}
void main()
{
auto c = immutable(S)(0);
writeln(c.oops()); // 0
writeln(c.oops()); // 1
writeln(c.oops()); // 2
writeln(c.oops()); // 3
writeln(c.oops()); // 4
writeln(c.oops()); // 5
}

They are not call with the same parameters. The hidden parameter have changed (I know this is tricky).


Explain it however you want.

The bottom line I'm getting at is, you can't re-order the calls, EVEN IF by "looking at them" you can tell they're pure @safe nothrow const...

Reply via email to