Fixing std.string
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Aug 20 00:11:36 PDT 2010
Russel Winder wrote:
> On Fri, 2010-08-20 at 02:22 +0000, dsimcha wrote:
> [ . . . ]
>> 1. How did it get to be this way? Why did it seem like a good idea at the
>> time to only support UTF-8 and only immutable strings?
>
> But isn't the thinking these days that immutable strings are a good
> thing?
>
> Immutability is generally a good thing for all parallel, and indeed
> concurrent, computations.
Hey Russell,
The idea is for the algorithms to impose as little on their inputs. If
you're searching a character in a string you wouldn't care whether the
string is mutable or not - the algorithm is the same. Currently many
algorithm in std.string require (a) immutable and (b) UTF-8 strings as
inputs. Either or both limitations should be relaxed as much as possible.
char[] thisIsMutable = new char[100];
char[] thisIsMutableW = new wchar[100];
...
assert(indexOf(thisIsMutable, "abc") != -1); // should work
assert(indexOf(thisIsMutableW, "abc") != -1); // should work
assert(indexOf(thisIsMutableW, "abc"w) != -1); // even this should work
Andrei
More information about the Digitalmars-d
mailing list