On Monday, 18 June 2012 at 15:11:00 UTC, Timon Gehr wrote:
On 06/18/2012 04:55 PM, Mehrdad 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 }Now you have managed to break the type system. The underlying issue is unrelated to delegates though.
Yeah, I didn't mean to say it's a delegate issue either. That's why the title was saying "how to break _const_". Delegates were just a means to an end. :)
So (**IMHO**) if that's really the case, we should really spend some time fixing the /design/ of const before the implementation... good idea or no?
