Should this work?

Manu turkeyman at gmail.com
Sat Jan 25 18:07:59 PST 2014


On 25 January 2014 20:15, Peter Alexander <peter.alexander.au at gmail.com>wrote:

> On Saturday, 25 January 2014 at 09:18:24 UTC, Manu wrote:
>
>> On 24 January 2014 21:49, Regan Heath <regan at netmail.co.nz> wrote:
>>
>>  On Fri, 24 Jan 2014 08:21:12 -0000, Jacob Carlborg <doob at me.com> wrote:
>>>
>>>  I would expect "contains" to take a element and check if it exists in
>>>> the
>>>> range.
>>>>
>>>>
>>> Except in the case of string, where we also want an overload taking more
>>> than a single element aka a substring.
>>>
>>
>>
>> A great example of when the string function should not be conflated with
>> the general function.
>>
>
> You always want the overload.
>
> 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? String
normalisation? What about when char and wchar strings are compared? (should
that should be handled transparently?)
Strings are special, they're almost always special, and rarely conflate
with generalisations well.
Strings almost always exposes special cases that aren't useful or relevant
for any other context.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140126/6eadd65d/attachment.html>


More information about the Digitalmars-d mailing list