Walter Bright , dans le message (digitalmars.D:147161), a écrit :
> On 10/20/2011 9:06 PM, Jonathan M Davis wrote:
>> It's this very problem that leads some people to argue that string should be
>> its own type which holds an array of code units (which can be accessed when
>> needed) rather than doing what we do now where we try and treat a string as
>> both an array of chars and a range of dchars. The result is schizophrenic.
> 
> Making such a string type would be terribly inefficient. It would make D 
> completely uncompetitive for processing strings.

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. 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.

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).

-- 
Christophe

Reply via email to