On Tuesday, 15 May 2012 at 23:36:38 UTC, Chad J wrote:
The idea /was/ to store the @instance variable with the object specifically to avoid complex indirections. Still have to trust programmers though :/

But you /can't/ store the @instance variable with the object. As per the language reference, immutables may be stored in ROM. If the object is immutable (and const objects might be immutable), then the @instance variable would be stored in ROM, in which case it physically couldn't change no matter how hard you tried (or it would vomit run-time errors or some undefined behavior). The only "workable" solution would be an immutable pointer to the mutable variable.

Link: http://dlang.org/const3.html

Reply via email to