<div dir="ltr">So the concern is that you have a Set of values with derived hashes, it gets encoded, and then a later run of the program decodes that payload, the hash values are different and performance suffers because collisions occur where they previously didn&#39;t? (Correctness would never be an issue, since collisions would still be resolved by testing equality.)<div><br></div><div>*Technically* that&#39;s possible, I suppose, if (1) the developer reordered the fields between runs, (2) the implementation of the hash function changed between language versions, or (3) it involved some sort of runtime nondeterminism or randomness. If we ignore the cases where the code or the runtime has to be recompiled, then only (3) applies, and I don&#39;t foresee the derived hashes being implemented non-deterministically.</div><div><br></div><div>For what it&#39;s worth, this doesn&#39;t seem like a problem that&#39;s unique to synthesized requirements—it could happen with any type that changed its hash or introduced nondeterminism.</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 16, 2017 at 8:01 PM Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">If I understand the question correctly, Robert&#39;s asking whether the possibility that hashes might differ on every execution would causes issues if, upon deserializing, one stumbles upon a hash collision which did not occur with the original hashes. And I suppose the answer to that is...yes?</div><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 16, 2017 at 6:16 PM, Tony Allevato via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">>From what I can tell the hash values of elements in a Set don&#39;t come into play during encoding/decoding: they&#39;re merely serialized as the sequence of their elements. <a href="https://github.com/apple/swift/blob/2e5817ebe15b8c2fc2459e08c1d462053cbb9a99/stdlib/public/core/Codable.swift#L4073-L4097" target="_blank">https://github.com/apple/swift/blob/2e5817ebe15b8c2fc2459e08c1d462053cbb9a99/stdlib/public/core/Codable.swift#L4073-L4097</a><div><br></div></div><div class="m_105108982940722089HOEnZb"><div class="m_105108982940722089h5"><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 16, 2017 at 4:06 PM Robert Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>How do unstable hash values play with Codable? If you encode and save a Set, might you have problems interacting with it in the future? (This is more a Codable question than Hashable, but I figure I might as well ask here) </div></div><div dir="auto"><div><br>On Aug 16, 2017, at 7:02 PM, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><br><div><blockquote type="cite"><div>On Aug 16, 2017, at 5:59 PM, Rudolf Adamkovic via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_105108982940722089m_8045663408688059101m_2715802862581252404Apple-interchange-newline"><div><div dir="auto"><div>That&#39;s great. Thanks!<br></div></div></div></blockquote><div><br></div><div>Yes, excellent news!  I am *really* looking forward to seeing this proposal make it into an Xcode release!</div><br><blockquote type="cite"><div><div dir="auto"><div><br>R+</div><div><br>On 17 Aug 2017, at 00:46, John McCall &lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div><blockquote type="cite"><div>On Aug 16, 2017, at 6:35 PM, Rudolf Adamkovič via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_105108982940722089m_8045663408688059101m_2715802862581252404Apple-interchange-newline"><div><span style="font-family:Helvetica;font-size:12px;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">This is fantastic news! Any chance of this landing in Swift 4.x instead of 5?</span><br style="font-family:Helvetica;font-size:12px;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"></div></blockquote><div><br></div>It it likely to be available in 4.1, but not 4.0.</div><div><br></div><div>John.</div><div><br><blockquote type="cite"><div><br style="font-family:Helvetica;font-size:12px;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"><span style="font-family:Helvetica;font-size:12px;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">R+</span><br style="font-family:Helvetica;font-size:12px;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"><br style="font-family:Helvetica;font-size:12px;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"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;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">On 17 Aug 2017, at 00:29, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br>Proposal Link: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0185-synthesize-equatable-hashable.md" target="_blank">https://github.com/apple/swift-evolution/blob/master/proposals/0185-synthesize-equatable-hashable.md</a><br><br>The review of SE-0185 “Synthesizing Equatable and Hashable conformance” ran from August 9…15, 2017. Feedback for the feature was glowingly positive, and the proposal is accepted.  The core team discussed the concerns raised in the feedback thread for the proposal.  Here are some rough notes (not intended to be exhaustive), but it is important to recognize that the proposal follows the design of the auto-synthesized Codable proposal, and that many of these same points were discussed when it came up:<br><br>- The core team feels that adding compiler magic for this case is reasonable because it solves an important user need, and doesn’t preclude the introduction of a more general feature (e.g. like a macro system, or Rust&#39;s ‘deriving’ feature) in the future.  When/if that feature is designed and built, the compiler magic can be replaced with standard library magic.<br><br>- The hash value of a type is not intended to be stable across rebuilds or other changes to the code.  It is ok to change if fields are reordered, the standard library changes the hash function, etc.  Tony pointed this out on-thread, saying:  The stdlib documentation for hashValue states &quot;Hash values are not guaranteed to be equal across different executions of your program. Do not save hash values to use during a future execution.”<br><br>- The code synthesized is meant to feel like a default implementation that you’re getting for free from a (constrained) extension on the protocol.  This is why conformance to the protocol itself is all that is required, not something like “AutoEquatable”.  <br><br>Many thanks to Tony Allevato for driving forward this proposal.  The patch just needs final code review now - I think we’re all looking forward to this landing, congrats!<br><br>Chris Lattner<span class="m_105108982940722089m_8045663408688059101m_2715802862581252404Apple-converted-space"> </span><br>Review Manager<br><br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></blockquote><br style="font-family:Helvetica;font-size:12px;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"><span style="font-family:Helvetica;font-size:12px;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">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;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"><span style="font-family:Helvetica;font-size:12px;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">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;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"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;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">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;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"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;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">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br></div></blockquote></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div></blockquote></div>