mutable, const, immutable guidelines

Ali Çehreli acehreli at yahoo.com
Wed Oct 16 10:43:22 PDT 2013


On 10/16/2013 10:23 AM, Daniel Davidson wrote:

 > On Wednesday, 2 October 2013 at 13:09:34 UTC, Daniel Davidson wrote:

 >> guidelines):
 >>
 >> 1. If a variable is never mutated, make it const, not immutable.
 >> 2. Make the parameter reference to immutable if that is how you will
 >> use it anyway. It is fine to ask a favor from the caller.

 > After trying for several days to use immutable with types containing
 > some mutable aliasing I have come to the conclusion that maybe rule
 > number one should be:
 >
 > If you have a type that has now or may ever have in the future any
 > mutable aliasing (e.g. inclusion of T[] or T1[T1] where Ts are mutable)
 > do not ever use the immutable keyword in any context as things just
 > break down.

I think this topic should be carried to the main newsgroup already. I am 
convinced that this is a language issue. :-/

 > Thanks,
 > Dan

Ali



More information about the Digitalmars-d-learn mailing list