const?? When and why? This is ugly!
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Sat Mar 7 13:15:40 PST 2009
grauzone wrote:
> 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?
Then it would happen even when you *know* you're the only one with a
reference. Worse, it'd happen multiple times if you modify multiple
characters in a row...
More information about the Digitalmars-d
mailing list