<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 10, 2017, at 14:48, Tony Allevato &lt;<a href="mailto:tony.allevato@gmail.com" class="">tony.allevato@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Aug 10, 2017 at 11:05 AM Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class="">[Proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0185-synthesize-equatable-hashable.md" target="_blank" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0185-synthesize-equatable-hashable.md</a>]</div><div class=""><br class=""></div>Hi, Tony. Glad to see this back again!<div class=""><br class=""></div><div class="">Overall I'm an enthusiastic +1. The restrictions and future work you've listed make sense, and I think this is the right starting place. I just have one thing I'd want to clarify:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">Any user-provided implementations of&nbsp;==&nbsp;or&nbsp;hashValue&nbsp;will override the default implementations that would be&nbsp;provided by the compiler.<br class=""></blockquote><br class="">Does this include implementations in (possibly constrained) protocol extensions? I assume yes, but that's probably worth calling out explicitly. Still, it could be confusing to some users.<br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">Yes, manual implementations added in extensions override the compiler-synthesized default:</div><div class=""><br class=""></div><div class="">Without constraints:</div><div class=""><div class="">(swift) struct Foo: Equatable { let x: Int }</div><div class="">(swift) Foo(x: 5) == Foo(x: 6)</div><div class="">// r0 : Bool = false</div><div class="">(swift) Foo(x: 5) == Foo(x: 5)</div><div class="">// r1 : Bool = true</div><div class="">(swift) extension Foo { static func ==(lhs: Foo, rhs: Foo) -&gt; Bool { return lhs.x % 2 == rhs.x % 2 } }</div><div class="">(swift) Foo(x: 5) == Foo(x: 6)</div><div class="">// r2 : Bool = false</div><div class="">(swift) Foo(x: 5) == Foo(x: 7)</div><div class="">// r3 : Bool = true</div></div><div class=""><br class=""></div><div class="">With constraints:</div><div class=""><div class="">(swift) struct Foo&lt;T: Equatable&gt;: Equatable { let t: T }</div><div class="">(swift) extension Foo where T == String { static func ==(lhs: Foo&lt;T&gt;, rhs: Foo&lt;T&gt;) -&gt; Bool { return lhs.t.characters.count == rhs.t.characters.count } }</div><div class="">(swift) Foo(t: "foo") == Foo(t: "bar")</div><div class="">// r0 : Bool = true</div><div class="">(swift) Foo(t: 5) == Foo(t: 7)</div><div class="">// r1 : Bool = false</div></div><div class=""><br class=""></div><div class="">I can update the text to make this explicit.</div></div></div></div></blockquote><br class=""></div><div>Ah, that's not quite the example I meant, <i class="">and</i>&nbsp;your example isn't a correct demonstration for the REPL. If you want to test the == that's used in the Equatable conformance, you have to call a function that's generic on Equatable.</div><div><br class=""></div><div>Anyway, this is the example I meant:</div><div><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div>protocol Annoying {}</div><div>extension Annoying {</div><div>&nbsp; static func ==(lhs: Self, rhs: Self) -&gt; Bool {</div><div>&nbsp; &nbsp; print("annoying")</div><div>&nbsp; &nbsp; return true</div><div>&nbsp; }</div><div>}</div><div>struct Foo: Equatable, Annoying {</div><div>&nbsp; let x: Int</div><div>}</div><div>print(Foo(x: 5) == Foo(x: 6))</div></blockquote><div><br class=""></div><div>I think the correct behavior here is to call the version from Annoying, but I can also see how that would be surprising.</div><div><br class=""></div><div>Jordan</div><br class=""></body></html>