Suggestion: Operator `in` for slices

Steven Schveighoffer schveiguy at
Tue Dec 21 17:00:49 UTC 2021

On 12/20/21 6:04 AM, Dennis wrote:
> On Sunday, 19 December 2021 at 18:31:46 UTC, Steven Schveighoffer wrote:
>> There's your answer -- make a custom type that allows `in` with an 
>> array-like structure.
> For the record, I'm not arguing in favor of `in` for slices. I'm just 
> baffled that whenever this comes up, the first thing people bring up is 
> the 'time complexity' argument.

One thing not really being discussed is that there is a difference 
between "some library" defining slow `in` operators, or slow `opIndex`, 
and dlang/Phobos doing it.

D picked the path of trying to ensure complexity consistency for `in`, 
but it's more of a stylistic rule, not necessarily a requirement.


More information about the Digitalmars-d mailing list