Should this work?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jan 25 18:20:17 PST 2014


On 1/25/14 6:07 PM, Manu wrote:
> On 25 January 2014 20:15, Peter Alexander <peter.alexander.au at gmail.com
> <mailto:peter.alexander.au at gmail.com>> wrote:
>     If this works:
>
>          contains("hello", "el");
>
>     then this should work:
>
>          contains([1, 2, 3, 4, 5], [2, 3]);
>
>     Special cases are pure evil. There's nothing special about strings
>     in this case.
>
>
> Does that work in all cases of strings wrt utf encodings?

Yes.

> String normalisation?

Not automatically, but you could do things such as 
find(haystack.byGrapheme, needle.byGrapheme).

> What about when char and wchar strings are compared?

Yes.

> (should that should be handled transparently?)

It is. D's stdlib is one of very few languages that can do this out of 
the box without converting one to the other.

> Strings are special, they're almost always special, and rarely conflate
> with generalisations well.

There is considerable evidence that the above is wrong.

> Strings almost always exposes special cases that aren't useful or
> relevant for any other context.

The special cases I found almost always involve whitespace (there is no 
obvious generalization of the notion). Other than that, UTF strings are 
nothing else but boring variable-length encodings.


Andrei



More information about the Digitalmars-d mailing list