string is rarely useful as a function argument
Walter Bright
newshound2 at digitalmars.com
Wed Dec 28 10:46:52 PST 2011
On 12/28/2011 10:35 AM, Peter Alexander wrote:
> On 28/12/11 6:15 PM, Walter Bright wrote:
>> If such a change is made, then people will use const string when they
>> mean immutable, and the values underneath are not guaranteed to be
>> consistent.
>
> Then people should learn what const and immutable mean!
>
> I don't think it's fair to dismiss my suggestion on the grounds that people
> don't understand the language.
People do what is convenient, and as endless experience shows, doing the right
thing should be easier than doing the wrong thing. If you present people with a
choice:
#1: string s;
#2: immutable(char)[] s;
sure as the sun rises, they will type the former, and it will be subtly
incorrect if string is const(char)[].
Telling people they should know better and pick #2 instead is a strategy that
never works very well - not for programming, nor any other endeavor.
More information about the Digitalmars-d
mailing list