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.