The problem with const proposals
guslay
guslay at gmail.com
Fri Dec 7 09:59:52 PST 2007
Here is my list so far (examples are just for illustration, I do not propose a syntax):
1- non-addressable constant value (we can distinguish two conceptual flavors)
a - constant primive (aka define)
b - enumeration
2- immutable value type (addressable)
- current const/invariant (they represent the same thing, don't they?)
ex. const int x = 42; const S s(0,0);
3- immutable reference type (aka pointer to const data)
a - reference immutable class
ex. const C c = new C(0,0);
b - pointer to immutable value
ex. const (T)* s; //ptr to const T
ex. const (T*) s; //const ptr to const T
4- aggregates (arrays etc)
a - mutable container of const data
ex. const(T)[]
b - immutable container of const data
ex. const(T[])
c - immutable container of mutable data
ex. ?? T[const]
5- non-rebindable value
- pointless, basically covered by 1
6- non-rebindable reference (aka const pointer to data)
a - to mutable data
ex. final S* s; final C;
b - to immutable data
ex. final const S* s; final const C;
There might be some overlap (eg. between 3b and 6).
More information about the Digitalmars-d
mailing list