I agree, the string parameters are indeed irritating, but changing the alias would bring much more pain, then it would relieve.
On Wed, Dec 28, 2011 at 4:06 PM, Peter Alexander <[email protected]> wrote: > string is immutable(char)[] > > 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. > > This is quite irritating because "string" is the most convenient and > intuitive thing to type. I often get into situations where I've written a > function that takes a string, and then I can't call it because all I have is > a char[]. I could copy the char[] into a new string, but that's expensive, > and I'd rather I could just call the function. > > I think it's telling that most Phobos functions use 'const(char)[]' or 'in > char[]' instead of 'string' for their arguments. The ones that use 'string' > are usually using it unnecessarily and should be fixed to use const(char)[]. > > In an ideal world I'd much prefer if string was an alias for const(char)[], > but string literals were immutable(char)[]. It would require a little more > effort when dealing with concurrency, but that's a price I would be willing > to pay to make the string alias useful in function parameters. -- Bye, Gor Gyolchanyan.
