https://issues.dlang.org/show_bug.cgi?id=14781
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #6 from [email protected] --- (In reply to Denis Shelomovskij from comment #5) > Then this function isn't strongly pure anymore: > --- > T f() pure; > --- > if `T` is `int delegate()`. > > Is everybody OK with this? I think that's already not strongly pure. `int delegate()` has a mutable indirection in the context pointer. So a function that returns such a delegate can't be strongly pure. See http://klickverbot.at/blog/2012/05/purity-in-d/#indirections_in_the_return_type An example with the delegate type: ---- struct S { int x = 1; int method() {return x++;} } int delegate() f() pure { return &(new S).method; } void main() { auto dg1 = f(); version(all) auto dg2 = f(); else auto dg2 = dg1; /* This would be equivalent to the above if f were strongly pure. */ import std.stdio; writeln(dg1()); /* "1" */ writeln(dg1()); /* "2" */ writeln(dg2()); /* "1" or "3", depending on the version above */ } ---- --
