[swift-evolution] Equatability for enums with associated values

Joe Groff jgroff at apple.com
Fri Jan 13 16:02:07 CST 2017


> On Jan 13, 2017, at 1:10 PM, Anton Zhilin via swift-evolution <swift-evolution at swift.org> wrote:
> 
> That seems pretty close to Rust’s derive. Why not invent a similar syntax in Swift? Otherwise it will make us look through all the sources to make sure deriving is used.
> 
> enum Option: @derive Equatable {
>     ...
> }

My feeling on this is that it feels strange to treat compiler-provided default implementations as different from library-provided default implementations. If the library provides a protocol extension with an appropriate default implementation for your type, you get it without any work on your part. While the Equatable/Hashable/Comparable conformance would most practically compiler generated today, you could imagine a far future version of Swift having sufficiently powerful generic type traits to do this in the library.

-Joe


More information about the swift-evolution mailing list