The Status of Const

Jonathan M Davis jmdavisprog at gmail.com
Thu Aug 12 17:48:02 PDT 2010


On Thursday, August 12, 2010 17:38:28 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.

Hence the hack that is Rebindable!().

Oh, and you _can_ achieve pointers to classes, but what you normally use are 
references, which do have the problem of not being able to be split between the 
reference and referent types.

- Jonathan M Davis


More information about the Digitalmars-d mailing list