reddit.com: first Chapter of TDPL available for free

Johan Granberg lijat.meREM at OVEgmail.com
Sun Aug 9 10:34:04 PDT 2009


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.



More information about the Digitalmars-d mailing list