<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, 2016, at 5:27 PM, Chris Lattner 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="">On Jan 22, 2016, at 3:10 PM, Jordan Rose via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><div class=""><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=""><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=""><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" 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="">Additionally, there is a hidden(?) feature in Swift that's imho quite cool:</div><div class="">The ability to call a function with a tuple containing the arguments</div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space"> </span>args = (<span class="" style="color: rgb(39, 42, 216);">4.0</span>, exponent:<span class="Apple-converted-space"> </span><span class="" style="color: rgb(39, 42, 216);">4.0</span>)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);">printPowWithBase<span class="">(</span><span class="" style="color: rgb(79, 129, 135);">args</span><span class="">)</span></div></div><div class=""><br class=""></div><div class="">In this case, you end up with a first parameter without any indication of its role.</div></div></div></blockquote><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class="">This feature is likely to get redesigned soon. (It has other problems.)</div></div></blockquote></div>Can you elaborate? I did not encounter many usecases yet, but I think it could be handy to configure a bunch of similar objects — and if it would be possible to capture the parameter tuple inside the called function, this could be forwarded to a function with the same signature easily… (especially, but not only the implementation of super)</div></div></blockquote><br class=""></div><div class="">In some contexts it's hard to distinguish between "the first parameter" and "the tuple of all parameters", and we have some weird inconsistencies where "foo(x)" and "foo((x))" do the same thing sometimes and different things other times.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Here’s a simple example to show the ambiguity:</div><div class=""><br class=""></div><div class="">func foo(a : Any…) {}</div><div class="">let x = (1,2,3)</div><div class="">foo(x) // 1 parameter or 3?</div><div class=""><br class=""></div><br class=""><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="">There's more complexity here but I don't have it paged in; it's not so relevant to this discussion</div></div></div></blockquote><br class=""></div><div class="">Incidentally, IMO the likely solution is for this to just make this explicit somehow. * isn’t really right right sigil for this, but you could imagine something like this:</div><div class=""><br class=""></div>printPowWithBase(*args)<br class=""><br class=""><div class="">Where the * (or whatever symbol actually makes sense) is a “flatten” or “expand inline” operation for the tuple argument. This makes it unambiguous whether splatting is happening or not.</div><div class=""><br class=""></div><div class=""><div class="">func foo(a : Any…) {}</div><div class="">let x = (1,2,3)</div><div class="">foo(x) // 1 parameter</div></div><div class="">foo(*x) // 3 parameters</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Alternatively, the argument could be made that we should just remove this splatting behavior. I haven’t heard of any super-compelling use-cases for it. Adding a sigil for this operation would expose the complexity that the behavior underlines.</div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>Use case:</div><div><br class=""></div><div>Zipping streams of arguments into tuples and then applying them through a function, and for the sake of argument, there's a big scary monster of necessity preventing you from consuming them at the same time using f($0, $1, $2, etc), so the lazy zipped tuple stream occurs at a different time/place as the consumption, which is not expecting a tuple input but n separate arguments.</div><div><br class=""></div><div>-- E</div><div><br class=""></div><div><br class=""></div><br class=""><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="">-Chris</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>