Const/Shared/Immutable anomalies in D that should be fixed

Mehrdad wfunction at hotmail.com
Wed May 2 23:00:57 PDT 2012


I believe all of these static assertions (and some variants thereof) should 
pass, due to the semantics of const, immutable, and shared.

immutable struct Immutable { }
const struct Const { }
shared struct Shared { }
static assert(is(Immutable == immutable(Immutable)));
static assert(is(Immutable == const(Immutable)));
static assert(is(Immutable == shared(Immutable)));
static assert(is(Const == const(Const)));
static assert(is(Const == shared(Const)));
static assert(is(Shared == shared(Shared)));


Do people agree?

Also, what exactly is the difference between declaring a struct as immutable 
or as const? Aren't they unmodifiable either way? 



More information about the Digitalmars-d mailing list