reddit.com: first Chapter of TDPL available for free

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Aug 9 11:11:20 PDT 2009


Johan Granberg wrote:
> Michel Fortin wrote:
> 
>> On 2009-08-09 11:10:48 -0400, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> said:
>>
>>>> It's also arguable that all functions in std.string should take
>>>> const(char)[]. Or, you know, const(T)[], since D supports encodings
>>>> other than UTF-8, despite what std.string leads you to believe.
>>> Yah, I think they should all be parameterized so they can work with
>>> various character widths and even encodings.
>> But shouldn't they work with *ranges* in general, a string being only a
>> specific case?
>>
> 
> I can give at least one example of this, I wrote some java code a while back
> and wanted t use string functions like findSubstring (wahtever its called)
> but my data was an array of bytes, as i could not convert the bytes to a
> string (possibly unknown encoding) i could not use the string functions
> even if they work on any type of values. If the string functions would work
> like subrange in this example i could use any range of values as a string
> (if i'm not missunderstanding it a string in teoretical computer siences is
> just a sequence of symbols). The same can be said of any string algorithm
> that does not specifically handle encodings.

Yes, perfect. And even those that do handle encodings could abstract 
things away by e.g. acknowledging that in certain modes of iteration one 
unit of interest is one ore more units of encoding.

Andrei



More information about the Digitalmars-d mailing list