const?? When and why? This is ugly!

grauzone none at example.net
Sat Mar 7 13:07:03 PST 2009


Walter Bright wrote:
> 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.

What about automatic, built-in copy on write?



More information about the Digitalmars-d mailing list