Simen kjaeraas Wrote: > Simen kjaeraas <simen.kja...@gmail.com> wrote: > > >> This way only mutable references are only ever assigned to it? Then it > >> can be marked as @trusted and used in safe code as it will never cause > >> the program to crash? > > > > Indeed it could. > > Wait. Correction: In the case when the object harboring the mutable > member is moved into read-only memory (I do not know if this might > actually happen), this ceases to be true. > > -- > Simen
Well, the error I get seems to indicate an issue with alias this: lconst.d(5): Error: function lconst.bar (int n) is not callable using argument types (Mutable!(int)) lconst.d(5): Error: cannot implicitly convert expression (a.n) of type Mutable!(int) to int So what you are saying is that Mutable should not work on value types right? So if we make these assertions: static assert(!__traits(compiles, new class { Mutable!int n; })); immutable A a = new immutable(A); int i = 8; static assert(!__traits(compiles, a.n = &i)); static assert(__traits(compiles, *a.n = i)); static assert(__traits(compiles, bar(a.n))); The last one being what I believe to be an alias this bug, the rest assert correctly: https://gist.github.com/721066