[swift-evolution] [Manifesto] Completing Generics
Dave Abrahams
dabrahams at apple.com
Thu Mar 3 18:24:58 CST 2016
on Wed Mar 02 2016, David Smith <swift-evolution at swift.org> wrote:
> The choice of Equatable as an example for opening existentials is an
> interesting one here, because it's one of the few cases I can think of
> where differing dynamic types is actually fully defined: they're not
> equal. In ObjC we express that by starting every -isEqual:
> implementation with if (![other isKindOfClass:[self class]]) { return
> NO; }, which while clunky and easy to forget, does neatly express the
> desired semantics with no burden at the callsite.
It's a reasonable default, but it's not necessarily the right
implementation for every type. One could imagine Polygons comparing
equal to Squares, for example.
--
-Dave
More information about the swift-evolution
mailing list