string is rarely useful as a function argument

mta`chrono chrono at mta-international.net
Wed Dec 28 05:30:24 PST 2011


I understand your intention. It was one of the main irritations when I
moved to D. Here is a function that unnecessarily uses string.

/**
 * replaces foo by bar within text.
 */
string replace(string text, string foo, string bar)
{
   // ...
}

The function is crap because it can't be called with mutable char[].
Okay, that's true. Therefore you'd suggested to alias const(char)[]
instead of immutable(char)[] ???

But I think inout() is your man in this case. If I remeber correctly, it
has been fixed recently.

I'm not quite sure if I got your point. So forgive me if I was wrong.



More information about the Digitalmars-d mailing list