digitalmars.D.bugs - [Issue 9148] New: 'pure' is broken
- d-bugmail puremagic.com (61/61) Dec 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9148
http://d.puremagic.com/issues/show_bug.cgi?id=9148 Summary: 'pure' is broken Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: timon.gehr gmx.ch - There is no way to specify that a delegate is strongly pure without resorting to type deduction, because - Member functions/local functions are handled inconsistently. - Delegate types legally obtained from certain member functions are illegal to declare. - 'pure' means 'weakly pure' for member functions and 'strongly pure' for local functions. Therefore it means 'weakly pure' for delegates, as those can be obtained from both. - Delegates may break the transitivity of immutable, and by extension, shared. A good first step in fixing up immutable/shared would be to make everything that is annotated 'error' pass, and the line annotated 'ok' should fail: import std.stdio; struct S{ int x; int foo()pure{ return x++; } int bar()immutable pure{ // return x++; // error return 2; } } int delegate()pure s(){ int x; int foo()pure{ // return x++; // error return 2; } /+int bar()immutable pure{ // error return 2; }+/ return &foo; } void main(){ S s; int delegate()pure dg = &s.foo; // int delegate()pure immutable dg2 = &s.bar; // error writeln(dg(), dg(), dg(), dg()); // 0123 immutable int delegate()pure dg3 = dg; // ok writeln(dg3(), dg3(), dg3(), dg3()); // 4567 // static assert(is(typeof(cast()dg3)==int delegate() immutable pure)); // error auto bar = &s.bar; pragma(msg, typeof(bar)); // "int delegate() immutable pure" } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 13 2012