<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="">Thanks for all your feedback!<div class=""><br class=""></div><div class=""><div class="">This is the current statistic:</div><div class="">Closure syntax: All positive</div><div class="">Function syntax: 3 (or 4) positive, 2 negative</div></div><div class=""><div class=""><br class=""></div><div class="">I’ll try to address the concern Geordie and T.J. have.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">func</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;takesATuple(someInt:&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Int</span><span class="" style="font-family: Menlo; font-size: 11px;">, tuple: (</span><span class="" style="font-family: Menlo; font-size: 11px;">valueA:&nbsp;</span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;">String</span><span class="" style="font-family: Menlo; font-size: 11px;">, valueB:&nbsp;</span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;">String</span><span class="" style="font-family: Menlo; font-size: 11px;">)</span><span class="" style="font-family: Menlo; font-size: 11px;">) {}</span></div></div></div></blockquote><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="">It’s true that you still have the ‚overhead‘ of having to type&nbsp;<i class="">tuple.</i>&nbsp;before accessing its members. But this is almost always what I want (hopefully you’d never actually name your tuple ‚tuple‘, instead it’d be a logical namespace for what it contains). Do you have a real-world example where you’d need this? To me it seems that in a case like this the API that produced the tuple would need refining rather than the language itself.</div></div></div></blockquote></div><div class=""><br class=""></div><div class="">What you suggest here is not tuple destructuring but using labeled tuples. And while I’m totally with you that this is for many cases the better approach, I still think we should introduce it to functions as well, for consistency and readability reasons.</div><div class="">In the end inconsistency is what led to this thread because tuple destructuring is already possible today - in for loops:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> stringTuple = [(</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"”</span><span style="font-variant-ligatures: no-common-ligatures" class="">), (</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span><span style="font-variant-ligatures: no-common-ligatures" class="">)]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (i, j) </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> stringTuple {}</span></div></div><div class=""><br class=""></div><div class="">That made me wonder if it’s also possible for closures (because I needed it there - and eventually someone will definitely wonder if it’s possible for function arguments as well).</div><div class=""><br class=""></div><div class="">You also asked me for my use case. To be honest, I don’t have one for the function version, but imagine the following:</div><div class=""><br class=""></div><div class="">My current closure use case is this (<span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">template.</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">points</span>&nbsp;and&nbsp;<span style="font-family: Menlo; font-size: 11px;" class="">resampledPoints</span>&nbsp;are of type&nbsp;<span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">[</span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">CGPoint</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">]</span>):</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> localHighestSimilarity = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">zip</span><span style="font-variant-ligatures: no-common-ligatures" class="">(template.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">points</span><span style="font-variant-ligatures: no-common-ligatures" class="">, resampledPoints).</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">reduce</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.0</span><span style="font-variant-ligatures: no-common-ligatures" class="">) { accumulator, points </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (template, resampled) = points</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> accumulator + </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class="">(template.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">x</span><span style="font-variant-ligatures: no-common-ligatures" class=""> * resampled.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">x</span><span style="font-variant-ligatures: no-common-ligatures" class=""> + template.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">y</span><span style="font-variant-ligatures: no-common-ligatures" class=""> * resampled.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">y</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">To reuse this code elsewhere I maybe want to refactor the closure into a function (using your labeled tuple suggestion):</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> accumulateSimilarity(accumulator: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class="">, for points: (point1: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGPoint</span><span style="font-variant-ligatures: no-common-ligatures" class="">, point2: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGPoint</span><span style="font-variant-ligatures: no-common-ligatures" class="">)) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> accumulator + </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class="">(points.point1.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">x</span><span style="font-variant-ligatures: no-common-ligatures" class=""> * points.point2.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">x</span><span style="font-variant-ligatures: no-common-ligatures" class=""> + points.point1.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">y</span><span style="font-variant-ligatures: no-common-ligatures" class=""> * points.point2.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">y</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div></div></div><div class="">This isn’t particularity readable (image passing a CGRect and you need the points or a more complex calculation). Compare it to this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> accumulateSimilarity(accumulator: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class="">,&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures" class="">for&nbsp;(point1, point2): (CGPoint, CGPoint)) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> accumulator + </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class="">(point1.x * point2.x + point1.y * point2.y)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><br class=""></div><div class="">You can of course still pass a named tuple instead of an unnamed, but it doesn’t make any difference, which brings me to an aside*.</div><div class=""><br class=""></div><div class="">I think the second approach makes the calculation much more comprehensible and it just feels “intuitive” (again, at least for me) :).</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">- Dennis</div></div>

</div><div class=""><br class="webkit-block-placeholder"></div><div class="">* I’m not sure how scientifically correct the following statement is but strictly speaking (at least for me)&nbsp;<span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">(valueA:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">String</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">, valueB:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">String</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">)</span>&nbsp;is not of the same type as&nbsp;<span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">String</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">,&nbsp;</span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">String</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">)</span>&nbsp;just like&nbsp;<span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">&nbsp;d(string:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">String</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">, int:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Int</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">)</span>&nbsp;is different from&nbsp;<span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">&nbsp;e(</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">_</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">String</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">,&nbsp;</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">_</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Int</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">)</span>&nbsp;though in Swift the tuples are interchangeable (you can pass one where the other is expected).</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On May 8, 2016, at 6:10 PM, Geordie J &lt;<a href="mailto:geojay@gmail.com" class="">geojay@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Comments below</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">Am 05.05.2016 um 20:22 schrieb Dennis Weissmann via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Following a short discussion with positive feedback on [swift-users](<a href="http://thread.gmane.org/gmane.comp.lang.swift.user/1812" class="">http://thread.gmane.org/gmane.comp.lang.swift.user/1812</a>) I’d like to discuss the following:</div><div class=""><br class=""></div><div class="">Tuples should be destructible into their components in parameter lists.</div><div class=""><br class=""></div><div class="">Consider the following code:</div><div class=""><br class=""></div><div class=""><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;a = [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;b = [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;c =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">zip</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">a</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">b</span><span class="" style="font-variant-ligatures: no-common-ligatures;">).</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">reduce</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) { acc, tuple</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">in</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; acc +&nbsp;tuple.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;+&nbsp;tuple.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></div></div><div class=""><font face="Menlo" class=""><span class="" style="font-size: 11px;">tuple</span></font>&nbsp;is of type&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">Int</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">,<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">Int</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">).</span></div><div class=""><br class=""></div><div class="">The problem is that the calculation is not very comprehensible due to&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0&nbsp;</span>and&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span>. That’s when destructuring tuples directly in the parameter list comes into play:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;c =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">zip</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">a</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">b</span><span class="" style="font-variant-ligatures: no-common-ligatures;">).</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">reduce</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) { acc,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(valueA, valueB)<span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">in</span></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; acc +&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">valueA&nbsp;+&nbsp;</span>valueB</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">+1 I think this is a great way to go about it.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class="">The above is what I propose should be accepted by the compiler (but currently isn’t).</div><div class=""><br class=""></div><div class="">Currently tuple destructuring is possible like this:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>c = zip(a,b).reduce(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) { (acc, tuple)<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">in</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>(valueA, valueB) = tuple</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">return</span>&nbsp;acc + valueA + valueB</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div></div><div class=""><br class=""></div><div class="">This is not about saving one line ;-). I just find it much more intuitive to destructure the tuple in the parameter list itself.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Agreed</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class="">The same thing could be done for functions:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>takesATuple(someInt:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, tuple: (</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;">))</span></div></div><div class=""><br class=""></div><div class="">Here we also need to destructure the tuple inside the function, but the intuitive place (at least for me) to do this would be the parameter list.</div><div class=""><br class=""></div><div class="">In the following example I'm making use of Swift’s feature to name parameters different from their labels (for internal use inside the function, this is not visible to consumers of the API):</div><div class=""><br class=""></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">&nbsp;takesATuple(someInt:&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">, tuple (valueA, valueB): (<span class="" style="color: rgb(112, 61, 170);">String</span>,&nbsp;<span class="" style="color: rgb(112, 61, 170);">String</span>))</span></div></div></div></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I’m not such a fan of this though. I realize what I’m about to write here is discussing a slightly different point but bear with me: I was under the impression it was already possible to do something like this (maybe only possible with typealiases):</div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);"><br class=""></span></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">func</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;takesATuple(someInt:&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Int</span><span class="" style="font-family: Menlo; font-size: 11px;">, tuple: (</span><span class="" style="font-family: Menlo; font-size: 11px;">valueA:&nbsp;</span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;">String</span><span class="" style="font-family: Menlo; font-size: 11px;">, valueB:&nbsp;</span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;">String</span><span class="" style="font-family: Menlo; font-size: 11px;">)</span><span class="" style="font-family: Menlo; font-size: 11px;">) {}</span></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px;"><br class=""></span></div><div class="">I find that syntax readable and extensible: you can make a type alias for your tuple type '<span class="" style="font-family: Menlo; font-size: 11px;">(</span><span class="" style="font-family: Menlo; font-size: 11px;">valueA:&nbsp;</span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;">String</span><span class="" style="font-family: Menlo; font-size: 11px;">, valueB:&nbsp;</span><span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;">String</span><font face="Menlo" class=""><span class="" style="font-size: 11px;">)‘</span></font>, you can then use it like this:</div><div class=""><br class=""></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">func</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;takesATuple(someInt:&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Int</span><span class="" style="font-family: Menlo; font-size: 11px;">, tuple: MyAliasedTupleType</span><span class="" style="font-family: Menlo; font-size: 11px;">) {</span></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp; print(tuple.valueA)</span></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px;">}</span></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px;"><br class=""></span></div><div class="">It’s true that you still have the ‚overhead‘ of having to type<span class="Apple-converted-space">&nbsp;</span><i class="">tuple.</i>&nbsp;before accessing its members. But this is almost always what I want (hopefully you’d never actually name your tuple ‚tuple‘, instead it’d be a logical namespace for what it contains). Do you have a real-world example where you’d need this? To me it seems that in a case like this the API that produced the tuple would need refining rather than the language itself.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class="">Here&nbsp;<span class="" style="font-family: Menlo; font-size: 11px;">valueA</span>&nbsp;and&nbsp;<span class="" style="font-family: Menlo; font-size: 11px;">valueB</span>&nbsp;would be directly usable within the function. The tuple as a whole would not be available anymore.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Now it’s your turn!</div><div class=""><br class=""></div><div class="">1. What do you think?</div><div class="">2. Is this worth being discussed now (i.e. is it implementable in the Swift 3 timeframe) or should I delay it?</div><div class=""><br class=""></div><div class="">Cheers,</div><br class=""><div class=""><div class="" style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">- Dennis</div></div></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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></div></div></blockquote></div><br class=""></div></div></body></html>