Why D have two function contains and canFind?

Seb via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 24 13:30:00 PDT 2017


On Monday, 24 July 2017 at 19:53:34 UTC, Cym13 wrote:
> On Monday, 24 July 2017 at 18:31:09 UTC, Ali Çehreli wrote:
>> On 07/24/2017 11:19 AM, Suliman wrote:
>> > [...]
>> only
>> > [...]
>>
>> std.algorithm.canFind and std.range.SortedRange.contains:
>>
>> [...]
>
> I'm gessing this predates design by introspection as it would 
> be cleaner to let the compiler do the switch itself.


Yes - since end of 2016 `find` (and thus `canFind`) do 
introspection:

https://github.com/dlang/phobos/pull/4907
https://github.com/dlang/phobos/blob/57b8d2511ea37cd01665b9b663d8ba246144b1f9/std/algorithm/searching.d#L1509

Thus, I believe it would be best to deprecate 
SortedRange.contains:

https://github.com/dlang/phobos/pull/5651


More information about the Digitalmars-d-learn mailing list