<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 3:51 AM, Robert Widmann 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=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><span class=""></span></div><div class=""><div class="">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="">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="">https://github.com/typelift/Valence/blob/cf4353c64de93b98c460529b06b8175c9ecfb79b/Tests/SystemF.swift#L161</a>).</div><div class=""><br class=""></div><div class="">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></div></div></blockquote><div><br class=""></div><div>We’re not discussing taking away recursive match are we? &nbsp;IIUC the discussion is limited to taking away matching all associated values as a single tuple, rather than matching each value individually.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div class=""><br class=""><div class="">~Robert Widmann</div></div><div class=""><br class="">2017/01/22 3:02、Daniel Duan &lt;<a href="mailto:daniel@duan.org" class="">daniel@duan.org</a>&gt; のメッセージ:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class="">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=""><br class=""></div><div class="">Care to share some examples, Robert?</div><div class=""><br class=""></div><div class="">- Daniel Duan</div><div class=""><br class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 21, 2017, at 11:00 PM, Robert Widmann &lt;<a href="mailto:devteam.codafi@gmail.com" class="">devteam.codafi@gmail.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 dir="auto" class=""><div class="">I find myself doing this <i class="">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=""><br class=""></div><div class="">~Robert Widmann</div><div class=""><br class="">2017/01/19 18:14、Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; のメッセージ:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><span class=""></span><br class=""><blockquote type="cite" class=""><span class="">On Jan 19, 2017, at 2:58 PM, Daniel Duan &lt;<a href="mailto:daniel@duan.org" class="">daniel@duan.org</a>&gt; wrote:</span><br class=""></blockquote><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><span class="">On Jan 19, 2017, at 2:29 PM, Joe Groff &lt;<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>&gt; wrote:</span><br class=""></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><span class="">On Jan 19, 2017, at 1:47 PM, Douglas Gregor via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</span><br class=""></blockquote></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><span class="">This looks totally reasonable to me. A couple of comments:</span><br class=""></blockquote></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><span class="">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=""></blockquote></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><span class="">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=""></blockquote></blockquote><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote><blockquote type="cite" class=""><span class="">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=""></blockquote><span class=""></span><br class=""><span class="">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=""><span class=""></span><br class=""><span class="">-Joe</span><br class=""><span class=""></span><br class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></div></div></blockquote></div></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>