Relaxing the definition of isSomeString and isNarrowString

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 23 18:39:09 PDT 2014


On Sat, Aug 23, 2014 at 06:06:37PM -0700, Andrei Alexandrescu via Digitalmars-d 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?
[...]

Recently there has been another heated debate on Github about whether
ranges should auto-decode at all:

	https://github.com/D-Programming-Language/phobos/pull/2423

Jonathan is about to write up a DIP for phasing out auto-decoding. Given
that, I think we need to decide which direction to take, lest we waste
energy on something that will be going away soon.


T

-- 
I don't trust computers, I've spent too long programming to think that they can get anything right. -- James Miller


More information about the Digitalmars-d mailing list