Const Variables

Ali Çehreli acehreli at yahoo.com
Mon Apr 4 18:20:31 UTC 2022


On 4/3/22 17:42, H. S. Teoh wrote:

 > In some sense, this is like an extension of ctors initializing immutable
 > values. The compiler tracks whether the variable has been initialized
 > yet, and inside the ctor you can assign to immutable because the
 > uninitialized value is not observable from outside before that. Once
 > assigned, the compiler enforces no subsequent changes.

These ideas make sense to me.

I remember reading somewhat similar requests in the past: Assign to a 
variable freely but at some point say "no more mutation to this variable".

Ali



More information about the Digitalmars-d-learn mailing list