Why the hell doesn't foreach decode strings
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Oct 28 06:07:50 PDT 2011
On 10/28/11 4:41 AM, Christophe Travert wrote:
> I definitely agree with you, but I have a piece of news for you :
> The whole phobos alreaday treats strings as a dchar ranges, and IS
> inefficient for processing strings.
>
> The fact is: char[] is not char[] in phobos. It is Range!dchar. This is
> aweful and schizophrenic, and also inefficient. The purpose was to allow
> people to use strings without knowing anything about unicode.
It was to allow people who know Unicode to use strings without too much
arcana.
> That is
> why Jonathan proposed having a specific string structure to manipulate
> strings without having to worry about unicode, just like how strings are
> currently manipulated in phobos, and letting char[] be char[], and be as
> efficient as they should be.
No need. Use
http://www.digitalmars.com/d/2.0/phobos/std_string.html#representation
> I was not there when it was decided to treat strings as dchar ranges,
> but now it is done. The only thing I can do is use ubyte[] instead of
> char[] so that phobos treat them as proper arrays, and propose optimized
> overloads for various phobos algorithm to make them as efficient as they
> should be (which I didn't find the time to do yet).
What would you have done if you were there? What is your design of choice?
Andrei
More information about the Digitalmars-d
mailing list