<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">@Xiaodi I have a slightly different view of this. Currently, if you have a type that conforms to a protocol, and you do not need to write any additional code in order for the type to conform to the protocol, then the protocol must have default implementations of its requirements. Because some types will be able to conform to Equatable/Hashable without writing out the code to satisfy the == and hashValue requirements, that logic (which you may or may not subscribe to) would dictate that there is a default implementation of those requirements (in this case, a magical default implementation that works for many different types; maybe it uses Mirrors) — it certainly “feels” like there is a default implementation to the user. And thus from an ergonomic standpoint, these issues are not really orthogonal, even if they are distinct implementation-wise.<div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 10, 2017, at 5:41 PM, David Ungar &lt;<a href="mailto:dungar@apple.com" class="">dungar@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">As long as I've been clear that the adoption of *this* proposal would transform a misspelling from a bug that the compiler catches to a bug that the compiler does not catch, I feel that my objection has been heard.<div class=""><br class=""></div><div class="">Thank you all,</div><div class=""><br class=""></div><div class="">- David<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Aug 10, 2017, at 1:51 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">Right. The objection raised is applicable to the overriding of any default implementation. However. _this_ proposal under review is about the synthesis of a default implementation, and we shouldn’t try to invent new syntax to address an orthogonal issue—and only partially at that.<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Aug 10, 2017 at 14:45 Robert Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</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" class="">Yes, thanks! Here’s the full proposal for those interested:&nbsp;<a href="https://github.com/erica/swift-evolution/blob/c541f517dacc2030c987b6d60ad3d26d8ec5fa3a/proposals/XXXX-role-keywords.md" target="_blank" class="">https://github.com/erica/swift-evolution/blob/c541f517dacc2030c987b6d60ad3d26d8ec5fa3a/proposals/XXXX-role-keywords.md</a><div class=""><br class=""></div><div class="">I think that if we want to deal with the issue of some mistake arising from conforming to Equatable and/or Hashable, it should be through that proposal, not something specific to Equatable and Hashable. This sort of issue should not count against this Equatable/Hashable proposal.</div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Aug 10, 2017, at 3:39 PM, Chris Lattner &lt;<a href="mailto:clattner@nondot.org" target="_blank" class="">clattner@nondot.org</a>&gt; wrote:</div><br class="m_940041053373071184Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class="m_940041053373071184Apple-interchange-newline">On Aug 10, 2017, at 12:24 PM, Robert Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">I could have sworn that this sort of issue came up on this list earlier this year… Someone proposed a mechanism encompassing all protocols, not just Equatable and Hashable, to handle the issue of mistakenly believing you’re overriding a default implementation. Having trouble finding it at the moment.<br class=""></blockquote><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">Is this what you’re thinking of?</span><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><a href="https://github.com/apple/swift-evolution/pull/724" style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" class="">https://github.com/apple/swift-evolution/pull/724</a><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">-Chris</span><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><blockquote type="cite" style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">.<br class=""><br class=""><blockquote type="cite" class="">On Aug 10, 2017, at 3:09 PM, David Ungar via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">If I understand it, merely adding Equatable or Hashable will cause the compiler to synthesize requirements. This syntax opens up the possibility for errors:<br class=""><br class="">struct Snort: Hashable {<br class="">static var hashValu /* NOTE MISSPELLING */ : Int { return 666 }<br class="">}<br class=""><br class="">In the above example, the programmer meant to implement hashValue but misspelled it.<br class="">With the proposal as-is, the error could be covered up.<br class=""><br class="">I would prefer to see a different syntax than merely adding conformance to "HashValue", in order to distinguish the two cases: explicit supplying the requirement vs synthesis.<br class=""><br class="">Also, what if we want to extend this idea to other protocols? Perhaps some sort of modifier on the protocol name would be more orthogonal:<br class=""><br class="">struct Foo: Synth Hashable, Equatable<span class="m_940041053373071184Apple-converted-space">&nbsp;</span><br class=""><br class="">Would say that Hashable requirements get synthesized but Equatable ones do not.<br class=""><br class="">Alternatively, it might be clearer, though more verbose to move the signalling inside:<br class=""><br class="">struct Snort: Hashable {<br class="">synth hashValue<br class="">}<br class=""><br class="">(I don't advocate this specific syntax, btw.) But it has the virtual of possibly making it clearer to read the code.<br class=""><br class="">TL;DR: I favor the proposal but would prefer modification to make it more explicit.<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></blockquote></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></body></html>