The Status of Const

Denis Koroskin 2korden at gmail.com
Fri Aug 13 22:09:45 PDT 2010


Graham St Jack Wrote:

> For me, the key problem is that a class object reference has the same 
> const/immutable/shared attribute as the object on the heap that it 
> refers to. This is sometimes what you need, but more often you want a 
> non-shared, mutable reference to a const/immutable/shared object.
> 
> You can achieve this with pointers for arrays, structs and primitive 
> types, but not with classes because a class pointer is just a pointer to 
> a reference.
> 

I discussed a possibility of requiring '*' to denote both references AND pointers before TDPL was out. It would solve a whole bunch of language issues, including this one:

Rebindable!(immutable(Foo)) bar; -> immutable(Foo)* bar;

There is a lot more benefits in the proposal than you might think at first. Here is the link: http://www.digitalmars.com/d/archives/digitalmars/D/What_if_D_would_require_for_reference_types_104816.html

> 
> -- 
> Graham St Jack
> 



More information about the Digitalmars-d mailing list