digitalmars.D.bugs - [Issue 9462] New: Delegate breaks immutability
- d-bugmail puremagic.com (43/43) Feb 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9462
- d-bugmail puremagic.com (9/9) Feb 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9462
http://d.puremagic.com/issues/show_bug.cgi?id=9462 Summary: Delegate breaks immutability Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: maxim maxim-fomin.ru --- This should not work, since alternative ways of doing so (including manual creation of delegate object and initialization of .ptr and .funcptr properties is rejected) are banned. import std.stdio; struct S { int i; void bar() { ++i; } void foo() immutable { //bar(); //error (&bar)(); //works, lang hole } } void main() { immutable S s; writeln(s.i); s.foo(); writeln(s.i); } dmd is smart enough to avoid delegate allocation, it just issues call directly to bar() -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 06 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9462 --- Forgot to mention: void delegate() dg = &bar; dg(); also is accepted. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 06 2013