On 28/12/11 5:11 PM, Walter Bright wrote:
On 12/28/2011 4:06 AM, Peter Alexander wrote:
I rarely *ever* need an immutable string. What I usually need is
const(char)[].
I'd say 99%+ of the time I need only a const string.

I have a very different experience with strings. I can't even remember a
case where I wanted to modify an existing string (this includes all my C
and C++ usage of strings). It's always assemble a string at one place,
and then refer to that string ever after (and never modify it).

We can disagree on this, but I think the fact that Phobos rarely uses 'string' and instead uses 'const(char)[]' or 'in char[]' speaks louder than either of our experiences.

What immutable strings make possible is treating strings as if they were
value types. Nearly every language I know of treats them as immutable
except for C and C++.

Yes, and I wouldn't want to remove that. Immutable strings are good, but requiring immutable strings when you don't need them is definitely not good. Phobos knows this, so it doesn't use string, which leads me to question what use the string alias is.

Reply via email to