const?? When and why? This is ugly!

Burton Radons burton.radons at gmail.com
Sat Mar 7 04:11:45 PST 2009


Walter Bright Wrote:

> When we first got into what to do with strings and 
> const/immutable/mutable, I was definitely in the camp that strings 
> should be mutable char[], or at worst const(char)[]. The thing is, 
> Andrei pointed out to me, languages that are considered very good at 
> dealing with strings (like Perl) use immutable strings. The fascinating 
> thing about strings in such languages is:
> 
> "Nobody notices they are immutable, they just work."

That's what we said about strings in 1.0. You modify it, you copy it, or you tell the user. The gentleman's agreement worked perfectly and that came without a mess of keywords, without implicit or explicit restrictions on behaviour, without having to condition templates.

Perl would be more powerful if its strings were mutable, not less, although not by much due to the interpreter.



More information about the Digitalmars-d mailing list