On Monday, 18 June 2012 at 14:55:42 UTC, 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
}



Heck, make that all @safe pure nothrow:

         int delegate() pure @safe nothrow increment;
auto oops() pure const @safe nothrow { return this.increment(); }

Reply via email to