[swift-evolution] Proposals: (1) Forbidding custom `==` for value types, (2) `dispatch` keyword, (3) `default`-result for methods with `Self`, and (4) Poor-Mans-Existentials

Saagar Jha saagarjha28 at gmail.com
Fri Jul 15 11:29:03 CDT 2016

Here's a value type that uses custom equality (at least, I think so):
String. Since it uses extended grapheme clusters, internally two Strings
may be composed of different Unicode scalars, but if they create the same
Characters they are considered to be equal.

On Fri, Jul 15, 2016 at 09:12 Johannes Neubauer via swift-evolution <
swift-evolution at swift.org> wrote:

> > Am 15.07.2016 um 15:19 schrieb Shawn Erickson <shawnce at gmail.com>:
> >
> > Additional two "things" maybe considered equal in the chosen problem
> domain despite their identity (memory location, etc.) being different.
> Having the ability to supply custom hash and equality for types can be a
> useful tool in a developers toolbox. For example two pathways of code may
> create what is actually the same thing (say a reference to the same file on
> disk) then want to work with stdlib set and/or dictionary with the
> equivalent things being resolved correctly, etc.
> >
> > To remove custom equality will limit some designs and to force identity
> based equality with present similar problems on the other end of the
> spectrum.
> It is only for value types. For reference types, which have an identity,
> you are right, but it doesn’t hold for values.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-Saagar Jha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160715/33c37367/attachment.html>

More information about the swift-evolution mailing list