June 19, 2007
Walter Bright Wrote:

> Johan Granberg wrote:
> > I don't think invariant here is such a great idea, consider the following function.
> > 
> > void foo(string s){}
> > 
> > if string is const this can be called with both char[] and const(char)[] (if
> > not please correct me) but if my understanding is correct char[] would not
> > work if string is invariant. This will lead to an unessesary amount of
> > cast(invariant) when calling functions on local strings (as functions that
> > create strings will have to modify the when they are being built).
> 
> That's essentially my argument against it, too. The other side is that treating strings as if they are value types is common and effective in other languages. (For example, strings in Perl are invariant.)

And in Python too!