Le 18/06/2012 17:16, Mehrdad a écrit :
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...

Yes, but this isn't a problem with pure here, this is a problem with const.

The sample code should not compile.

Reply via email to