[swift-evolution] [Draft] Automatically deriving Equatable and Hashable for certain value types

David Sweeris davesweeris at mac.com
Mon May 30 15:45:09 CDT 2016

What about declaring the requirements for auto-conformance in a sub-protocol?
@auto protocol AutoEquatable : Equatable {
    //"syntax" for how to conform to Equatable

struct Foo : AutoEquatable {} //the compiler automatically synthesizes everything
struct Bar : Equatable {} //you manually conform

It would be a compiler error to conform to an `@auto` protocol if the compiler couldn't apply the provided "syntax" to the conforming type.

(I have no clue what this "syntax" could be, other than some expansion of generics and/or a macro system)

Anyway, does that help? It satisfies both the "explicit conformance" crowd and the "no new keywords" (at least at the "call" site) crowd.

- Dave Sweeris

> On May 30, 2016, at 15:26, Vladimir.S via swift-evolution <swift-evolution at swift.org> wrote:
> I see these two groups: both wants explicit conformance to protocols, but first thinks that current syntax is enough (`: Equatable`) and second thinks we should introduce new keyword `deriving` for this(`: deriving Equatable`). I see no opinions(except the one opinion in proposal itself) to automatically deriving without explicit decoration.

More information about the swift-evolution mailing list