The problem with const proposals

Graham St Jack Graham.StJack at internode.on.net
Tue Dec 11 13:59:42 PST 2007


On Fri, 07 Dec 2007 12:59:52 -0500, guslay wrote:

> 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).

Don't forget const and invariant methods and all that goes with them.




More information about the Digitalmars-d mailing list