<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 22, 2017, at 8:30 AM, Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">Which is another reason we should be auto-deriving Equatable.<br class=""><br class="">Couldn't variation generics help here? If someone wanted to capture the whole argument list as a single tuple, we could require that they do it as a parameter pack? It's essentially the inverse of the tuple splat already mentioned in that section of the generics manifesto.<br class=""></div></blockquote><div><br class=""></div><div>Yeah, I agree that the lack of auto-derived Equatable is the real problem here. It would also definitely make sense to include variadic patterns as part of a future variadic generics design.</div><div><br class=""></div><div>-Joe</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Sun, Jan 22, 2017 at 7:42 AM T.J. Usiyan 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 dir="ltr" class="gmail_msg">Implementing equality would be made tedious again if we lose this.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">```</div>enum Jams : Equatable {<br class="gmail_msg"><br class="gmail_msg">&nbsp; &nbsp; case dmsr(Bool)<br class="gmail_msg">&nbsp; &nbsp; case kiss(Bool, Bool)<br class="gmail_msg">&nbsp; &nbsp; case pheromone(Int, Bool, Int)<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">&nbsp; &nbsp; public static func ==(lhs:Jams, rhs:Jams) -&gt; Bool {<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; switch (lhs, rhs) {<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; case let (.dmsr(left), .dmsr(right)):<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return left == right<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; case let (.kiss(left), .kiss(right)):<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return left == right<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; case let (.pheromone(left), .pheromone(right)):<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return left == right<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; case (.dmsr, _), (.kiss, _), (.pheromone, _):<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false<br class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; }<br class="gmail_msg">&nbsp; &nbsp; }<br class="gmail_msg">}<div class="gmail_msg">```<br class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Sun, Jan 22, 2017 at 4:51 AM, Robert Widmann via swift-evolution <span dir="ltr" class="gmail_msg">&lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"></span></div><div class="gmail_msg"><div class="gmail_msg">Sure.&nbsp; One of the first gadgets I wrote was a way of destructuring an array into a familiar cons-list kind of enum (<a href="https://github.com/typelift/Basis/blob/master/Basis/Array.swift#L9" class="gmail_msg" target="_blank">https://github.com/typelift/Basis/blob/master/Basis/Array.swift#L9</a>) which you use something like this with other non-trivial enums (<a href="https://github.com/typelift/Valence/blob/cf4353c64de93b98c460529b06b8175c9ecfb79b/Tests/SystemF.swift#L161" class="gmail_msg" target="_blank">https://github.com/typelift/Valence/blob/cf4353c64de93b98c460529b06b8175c9ecfb79b/Tests/SystemF.swift#L161</a>).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It's not strictly a problem for me to lose this feature, but it is gonna be a bit weird if we lose recursive match but also allow it for just plain old tuple patterns.</div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg">~Robert Widmann</div></div><div class="gmail_msg"><br class="gmail_msg">2017/01/22 3:02、Daniel Duan &lt;<a href="mailto:daniel@duan.org" class="gmail_msg" target="_blank">daniel@duan.org</a>&gt; のメッセージ:<br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg m_1735260278596306363h5"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">FWIW, in all public Github repos with 5k+ stars whose language gets recognized as “Swift”, 576 enum cases has associated values and among them 55 has 2 values or more. After some very casual grepping I didn’t find a lot of usage of this particular pattern.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Care to share some examples, Robert?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">- Daniel Duan</div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 21, 2017, at 11:00 PM, Robert Widmann &lt;<a href="mailto:devteam.codafi@gmail.com" class="gmail_msg" target="_blank">devteam.codafi@gmail.com</a>&gt; wrote:</div><br class="gmail_msg m_1735260278596306363m_4667549732735053882Apple-interchange-newline"><div class="gmail_msg"><div dir="auto" class="gmail_msg"><div class="gmail_msg">I find myself doing this <i class="gmail_msg">a lot</i>, but maybe my problems are just more Algebra-shaped than most.&nbsp; That said, I appreciate this cleanup and lean +1 (because you mentioned a way to partly keep this behavior).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">~Robert Widmann</div><div class="gmail_msg"><br class="gmail_msg">2017/01/19 18:14、Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; のメッセージ:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg">On Jan 19, 2017, at 2:58 PM, Daniel Duan &lt;<a href="mailto:daniel@duan.org" class="gmail_msg" target="_blank">daniel@duan.org</a>&gt; wrote:</span><br class="gmail_msg"></blockquote><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg">On Jan 19, 2017, at 2:29 PM, Joe Groff &lt;<a href="mailto:jgroff@apple.com" class="gmail_msg" target="_blank">jgroff@apple.com</a>&gt; wrote:</span><br class="gmail_msg"></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg">On Jan 19, 2017, at 1:47 PM, Douglas Gregor via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</span><br class="gmail_msg"></blockquote></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg">This looks totally reasonable to me. A couple of comments:</span><br class="gmail_msg"></blockquote></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg">1) Because this proposal is breaking the link between the associated value of an enum case and tuple types, I think it should spell out the rules that switch statements will use when matching an enum value against a a case with an associated value. Some kind of rules fell out of them being treated as tuple types, but they might not be what we want.</span><br class="gmail_msg"></blockquote></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><span class="gmail_msg">I was about to bring up the same. Right now, an enum pattern works like .&lt;identifier&gt; &lt;tuple-pattern&gt;, where the &lt;tuple-pattern&gt; then recursively matches the payload tuple. In this model, it seems like we'd want to treat it more like .&lt;identifier&gt;(&lt;pattern&gt;, &lt;pattern&gt;, ...). Similar to how we lost "tuple splatting" to forward a bunch of arguments, we'd have to decide whether we lose the ability to match all parts of the payload into a tuple.</span><br class="gmail_msg"></blockquote></blockquote><blockquote type="cite" class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"></blockquote><blockquote type="cite" class="gmail_msg"><span class="gmail_msg">I’m leaning towards “no” for simplicity of the language (and implementation). That means this would be source-breaking 😞.&nbsp; Will update the proposal and see how the rest of the feedback goes.</span><br class="gmail_msg"></blockquote><span class="gmail_msg"></span><br class="gmail_msg"><span class="gmail_msg">It'd be a good idea to try to find examples of people doing this out in the wild too, to see how widespread it is as well as how onerous the workarounds for losing the feature would be.</span><br class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"><span class="gmail_msg">-Joe</span><br class="gmail_msg"><span class="gmail_msg"></span><br class="gmail_msg"><span class="gmail_msg">_______________________________________________</span><br class="gmail_msg"><span class="gmail_msg">swift-evolution mailing list</span><br class="gmail_msg"><span class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a></span><br class="gmail_msg"><span 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></span><br class="gmail_msg"></div></blockquote></div></div></blockquote></div><br class="gmail_msg"></div></div></div></blockquote></div></div></div></div><br class="gmail_msg">_______________________________________________<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">
<br class="gmail_msg"></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>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>