On Sunday, 24 August 2014 at 01:06:31 UTC, Andrei Alexandrescu
wrote:
Currently char[], wchar[], dchar[] and qualified variants
fulfill the requirements of isSomeString. Also, char[], wchar[]
and qualified variants fulfill the requirements of
isNarrowString.
Various algorithms in Phobos test for these traits to optimize
away UTF decoding where unnecessary.
I'm thinking of relaxing the definitions to all types that
fulfill the following requirements:
* are random access ranges
* element type is some character
* offer .ptr as a @system property that offers a pointer to the
first character
This would allow us to generalize the notion of string and
offer optimizations for user-defined, not only built-in,
strings. Thoughts?
Andrei
One issue is that strings are "auto decoded", yet a range of
"char" is not. I don't see why ".ptr" is needed (or .length) for
that matter. We could very well have a range of chars that
doesn't of length, nor .ptr, but should still be handled like a
sequence of decoded characters.
I don't see how your proposal caters to that more generic problem
that a UD char range is not auto-decoded (or more generally, that
it will be handled *differently* from a string).