digitalmars.D - to const or not to const
class A { private int[] Xrg; int[] rg() const { return Xrg; } } void f(invariant A a) { a.rg[0]=0; }
May 10 2008
class desing, but you can't take slices, if you want substring, you make it. Arays there are always mutable, and how do you really need an array slice? D strings are char arrays modified with language-level attribute, in .Net String is a mutable object with immutable content, and immutability is achieved through class-level implementation. Do we really need const for immutable strings and do we really need strings to be arrays?
May 10 2008