Latest const expansion

Regan Heath regan at netmail.co.nz
Tue Sep 11 10:45:33 PDT 2007


Alexander Panek wrote:
> Regan Heath wrote:
>> Thoughts?  Too complicated?  :P
> 
> It's a tad complicated, but makes sense. More sense - to me - than the 
> former const/invariant/final and the upcoming const/invariant 
> combinations. At least you summed it up in a way so I understand it. :)
> 
> Yet, I have some questions:
> -- 
> class A { int i; }
> 
> const(*A) a;
> -- 
> Do I understand correctly? The variable `a' - as in a reference to an 
> instance of `class A' is mutable, but the instance `a' refers to is not? 
> (read as: `class A { const { int i; ... } }', just for this instance 
> reference) This also means, that you can reference to another instance 
> with `a':
> -- 
> a = b;
> -- 
> Right?

Correct.

> -- 
> const(&A) a;
> -- 
> This means, that the reference to the class instance is not mutable, yet 
> the actual instance is?

Correct.

> What exactly do `const(T)[]' and `const(T)*' imply? Immutable data, or 
> immutable reference/pointer?

Immutable data.

Regan



More information about the Digitalmars-d mailing list