I think it is better to create a syntax for getting the associated values and then comparing them.<br><br>enum Option {<br>    case foo(String)<br>    case bar(Int)<br>        case zip<br>}<br><br>let op = Option.foo(&quot;hello&quot;)<br>let bb = Option.foo(&quot;world&quot;)<br><br>// proposed tuple-like syntax<br><br>op.foo.0 // returns Optional(&quot;hello&quot;)<br><br>// then we can compare values directly<br><br>if op.foo.0 == bb.foo.0 {<br>// ...<br>}<br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 13, 2017 at 5:44 PM Slava Pestov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">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 style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 13, 2017, at 2:30 PM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-5931170447479371561Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">On Jan 13, 2017, at 15:10, Anton Zhilin via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="m_-5931170447479371561markdown-here-wrapper gmail_msg"><p style="margin:0px 0px 1.2em!important" class="gmail_msg">That seems pretty close to Rust’s <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="gmail_msg">derive</code>. Why not invent a similar syntax in Swift? Otherwise it will make us look through all the sources to make sure deriving is used.</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class="gmail_msg"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="gmail_msg">enum Option: @derive Equatable {
    ...
}
</code></pre><p style="margin:0px 0px 1.2em!important" class="gmail_msg">Also, we can get better looking compilation errors, like:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class="gmail_msg"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="gmail_msg">ERROR at line 1, col 14: could not derive Equatable for Option
enum Option: @derive Equatable {
             ^~~~~~~~~~~~~~~~~</code></pre></div></div></blockquote><br class="gmail_msg"><div class="gmail_msg">I think that idea came up once before... can&#39;t remember where, though, or what we thought of it at the time.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">As far as reducing enum boilerplate, what about borrowing the generic system&#39;s syntax and looking at it from the switch&#39;s PoV?</div><div class="gmail_msg">func == (lhs: MyEnum, r<span style="background-color:rgba(255,255,255,0)" class="gmail_msg">hs: MyEnum) -&gt; Bool {</span></div><div class="gmail_msg">    switch &lt;c is MyEnum&gt; (lhs, rhs) {</div><div class="gmail_msg">    case (c(let lVal), c(let rVal)): // both lhs and rhs are &quot;c&quot; and the same case</div><div class="gmail_msg">        return lVal == rVal //syntax error if `==` isn&#39;t defined for the associated value types of every case</div><div class="gmail_msg">    default: return false</div><div class="gmail_msg">    }</div><div class="gmail_msg">}</div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">I think initially, we would like to implement deriving these witnesses directly in the compiler, instead of trying to come up with a metaprogramming syntax for them.</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Slava</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">- Dave Sweeris</div></div>_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div><br class="gmail_msg"></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>