digitalmars.D - D2: immutable/const and delegates
- klickverbot (21/21) Sep 08 2010 I always thought I had understood the new const/immutable system of D2.
- klickverbot (3/5) Sep 08 2010 Ah, never mind, there is even a (more than two years old!) bug report
I always thought I had understood the new const/immutable system of D2. But now this: --- import std.stdio; class A { void setI( int newI ) { i = newI; } int i; } void main() { immutable a = new immutable(A); writefln( "Before: %s", a.i ); ( &a.setI )( 42 ); writefln( "After: %s", a.i ); } --- I would expect this not to compile, but for some reason it does (and the assignment works, a.i is 42 after the call to setI). Am I severely misunderstanding something here, or is this a rather big hole in the type system?
Sep 08 2010
On 9/8/10 11:46 AM, klickverbot wrote:Am I severely misunderstanding something here, or is this a rather big hole in the type system?Ah, never mind, there is even a (more than two years old!) bug report about it: http://d.puremagic.com/issues/show_bug.cgi?id=1983
Sep 08 2010