[swift-evolution] Equatable auto-write func == Proposal

Tony Allevato allevato at google.com
Mon Sep 12 10:43:20 CDT 2016


I started on an early-draft proposal for something like this a while back:
https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad

Most of the discussion in the e-mail thread (I don't have time to fetch the
link right now, unfortunately) was around how implicit/explicit such
behavior should be (i.e., should there be a keyword that you have to use to
buy into the automated implementation).

Given that it's additive, it's unlikely that it would be discussed now, but
I'd like to revisit it when the time is right.

On Mon, Sep 12, 2016 at 8:36 AM Daniel Tartaglia via swift-evolution <
swift-evolution at swift.org> wrote:

> Now that Swift 3 is out the door, I’m going to float this proposal again…
>
> Given that every value type should be equatable (rational here):
> https://www.andrewcbancroft.com/2015/07/01/every-swift-value-type-should-be-equatable/
> And that many, if not most, value types consist of properties that are
> value types.
> Then the language should make it easy to conform to the Equatable protocol.
>
> In other words, if I declare my value type as Equatable, and it is
> exclusively composed of value types that are already equatable, then
> implementing the actual == function should be optional (or maybe even
> forbidden.)
>
> Implementing == in such cases is tedious boilerplate that the compiler
> should be able to infer on its own.
>
> Does anybody want to help me write up an official proposal?
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160912/ecf5033c/attachment.html>


More information about the swift-evolution mailing list