<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I like the spirit of this idea because it matches features found in other languages that have prominent pattern matching (ML, Haskell, etc.). But I’m concerned about the overloading of existing syntax for this case. Plus, if you find yourself destructuring large enum cases like this, have you considered making a struct containing those fields?<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">enum</span> Value {</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">struct</span> Leaf {</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">let</span> data: <span style="color: #ba2da2" class="">Any</span>?, moreData: <span style="color: #ba2da2" class="">Any</span>?, evenMoreData: <span style="color: #ba2da2" class="">Any</span>?</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">case</span> container(leafs: [<span style="color: #4f8187" class="">Value</span>])</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">case</span> leaf(<span style="color: #4f8187" class="">Leaf</span>)</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> foo(<span style="color: #ba2da2" class="">_</span> v : <span style="color: #4f8187" class="">Value</span>) {</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span>switch<span style="color: #000000" class=""> v {</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">case</span> <span style="color: #ba2da2" class="">let</span> .<span style="color: #31595d" class="">leaf</span>(x):</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span><span style="color: #3e1e81" class="">print</span><span style="color: #000000" class="">(</span><span style="text-decoration: underline ; color: #000000" class="">x</span><span style="color: #000000" class="">.</span>data<span style="color: #000000" class="">, x.</span>moreData<span style="color: #000000" class="">, x.</span>evenMoreData<span style="color: #000000" class="">)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(49, 89, 93); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span><span style="color: #ba2da2" class="">case</span><span style="color: #000000" class=""> .</span>container<span style="color: #000000" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span>break</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div><div class="">~Robert Widmann</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 10, 2017, at 8:35 AM, Sash Zats via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi, I wanted to propose a better handling of enum cases with associated value<div class="">(somewhat) detailed proposal is here <a href="https://github.com/zats/swift-evolution/blob/master/proposals/0181-better-handling-of-enum-cases-with-associated-values.md" class="">https://github.com/zats/swift-evolution/blob/master/proposals/0181-better-handling-of-enum-cases-with-associated-values.md</a></div><div class="">I'm not sure I can suggest good detailed implementation since I'm not too familiar with Swift internals</div><div class="">But i'm sure it's something I can research if proposal makes sense to community</div><div class="">Since I havne't communicated through this mailing list, I'm not sure what's the etiquette, let me know if something is missing from the proposal.</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=""></div></body></html>