<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=""><div class=""><scratches head> Then I’ve misunderstood what splatting was. Is the difference between splatting and what my example does the arguments’ labels?</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> f(a : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> b : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>) {…}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> x = </span>FunctionApplicator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">((</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">42</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, b: </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">19</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">), f)</span><span style="color: rgb(0, 0, 0);" class=""> </span><span style="color: rgb(0, 132, 0);" class="">//Would stay legal, because of the "b:"</span></div></div><div class=""><div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">let</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class=""> y = </span><font color="#4f8187" face="Menlo" class=""><span style="font-size: 11px;" class="">FunctionApplicator</span></font><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">((</span><span style="color: rgb(39, 42, 216); font-family: Menlo; font-size: 11px;" class="">42</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">, </span><span style="color: rgb(39, 42, 216); font-family: Menlo; font-size: 11px;" class="">19</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">), f)</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class=""> </span><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">//Would become illegal, because there’s no “b:”</span></font></div></div></div><div class=""><br class=""></div><div class="">And we would have to use the <i class="">internal</i> argument labels? If so, how would that work with functions in 3rd-party libraries, where we might not have access to that information?</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Jan 27, 2016, at 10:21, Chris Lattner <<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 27, 2016, at 9:27 AM, Dave 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=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Fair enough. Can we get an explicit, well-designed version of this before we get rid of the implicit, poorly-designed version?</div></div></blockquote><div class=""><br class=""></div><div class="">I’m certainly not opposed to someone exploring this, but I don’t think it should block removing the bad thing.</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I can’t recall off the top my head where, but I <i class="">know</i> I’ve done something like this:</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="">struct</span> FunctionApplicator <T, U> {</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="">var</span> args: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</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="">let</span> function: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span> -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">U</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="">init</span>(args: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>, function: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span> -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">U</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="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">args</span> = args</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="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">function</span> = function</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> }</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="">func</span> apply() -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">U</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="" class=""> </span>function<span style="" class="">(</span>args<span style="" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div><div class="">Without tuple splatting, you’d need a <span style="font-family: Menlo; font-size: 11px;" class="">FunctionApplicator1<T,U></span>, <span style="font-family: Menlo; font-size: 11px;" class="">FunctionApplicator2<T,U,V></span>, <span style="font-family: Menlo; font-size: 11px;" class="">FunctionApplicator3<T,U,V,W></span>, etc. They can’t even have the same name because Swift doesn’t support overloading type names for types with a different number of generic parameters.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Perhaps I’m misunderstanding, but that is certainly not the case. Even without the feature in question you can definitely pass a tuple around as a single argument, e.g.:</div><div class=""><br class=""></div><div class="">func f(a : Int, _ b : Int) {…}</div><div class=""><br class=""></div><div class="">let x = FunctionApplicator((42, b: 19), f)</div><div class=""><br class=""></div><div class="">This functionality won’t be affected by removal of this feature.</div><div class=""><br class=""></div><div class="">-Chris</div></div></div></div></blockquote></div><br class=""></body></html>