const?? When and why? This is ugly!

Walter Bright newshound1 at digitalmars.com
Sat Mar 7 10:59:37 PST 2009


Burton Radons wrote:
> 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.

The one flaw in it was the behavior I consistently saw of "I'm copying 
the string just to be sure I own it and nobody else changes it." D was 
meant for copy-on-write, which means copy the string *only* if you 
change it. No defensive copying. No "just in case" copying. The 
gentleman's agreement failed as far as I could tell.

With immutable strings, the gentleman's agreement is enforced.



More information about the Digitalmars-d mailing list