Ahh… ok… so it sounds like the suggestion then is:
- ship
isIdentical
on concrete types in standard library and foundation - do not ship a standalone
Distinguishable
protocol - potentially add a new function to
Equatable
to expose the identity equality
This makes sense. I can agree with these ideas.
Correct. One of the places I could see this leading to measurable impact is an Observable
type (that is Equatable
and offers identity equality) that then recomputes a SwiftUI component body
. The current plan is to ship a linear-time equality check inside Observable
that filters new values before notifying observers.[1] But this could potentially then make use of identity equality before notifying SwiftUI (which we assume might perform its own linear-time operation when values have changed).
Correct. It gets bulky and clunky. My original thoughts were that increased flexibility from a Distinguishable
independent of Equatable
meant Distinguishable
could be adopted by types like Span
and RawSpan
that do expose identity equality but do not expose value equality. But the argument you are making is those potential wins from the extra flexibility are not worth it when we consider the extra gymnastics and ceremony that would go into using Distinguishable
from generic contexts that might also need to be generic over Equatable
. Makes sense. I can agree with this.
Yeah… I'm agreeing with this.
All good ideas. Thanks!