The Status of Const

Adam Ruppe destructionator at gmail.com
Thu Aug 12 19:23:30 PDT 2010


On the subject of rebindable, what about:

const Object o; // not rebindable, the whole thing is set once and const
const(Object) o; // the Object is const, but the reference is not.

So, everything is rebindable unless the declaration has a
const/immutable on the outside.

int a; // rebindable (obviously)
const(int) a; // the int never changes... but the variable a might.
Meaningless for a value type, but makes sense for a reference type
const int a; // the whole thing is set once and never changes. The
const applies to the variable a itself, but the transitive property
propagates it down to the int type too.


More information about the Digitalmars-d mailing list