<div>On Tue, 20 Jun 2017 at 01:41, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello Swift community,<div><br></div><div>Swift 3’s <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md" target="_blank">SE-0110</a> eliminated the equivalence between function types that accept a single type and function types that take multiple arguments. However, for various <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170612/037560.html" target="_blank">implementation reasons</a>, the implementation of SE-0110 (as well as the elimination of tuple “splat” behavior in <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0029-remove-implicit-tuple-splat.md" target="_blank">SE-0029</a>) was not fully completed.</div><div><br></div><div>Swift 4 implemented more of SE-0110, which caused a fairly serious usability regression, particularly with closures. Here are a few simple examples involving closures that worked in Swift 3 but do not work in Swift 4:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="Menlo">// #1: Works in Swift 3, error in Swift 4</font></div></div><div><div><font face="Menlo">myDictionary.forEach {</font></div></div><div><div><font face="Menlo"> print("\($0) -> \($1)")</font></div></div><div><div><font face="Menlo">}</font></div></div><div><div><font face="Menlo"><br></font></div></div><div><div><font face="Menlo">// #2: Works in Swift 3, error in Swift 4</font></div></div><div><div><font face="Menlo">myDictionary.forEach { key, value in</font></div></div><div><div><font face="Menlo"> print("\(key) -> \(value)")</font></div></div><div><div><font face="Menlo">}</font></div></div><div><div><font face="Menlo"><br></font></div></div><div><div><font face="Menlo">// #3: Works in Swift 3, error in Swift 4</font></div></div><div><div><font face="Menlo">myDictionary.forEach { (key, value) in</font></div></div><div><div><font face="Menlo"> print("\(key) -> \(value)")</font></div></div><div><div><font face="Menlo">}</font></div></div></blockquote><div><br></div><div>Similar issues occur with passing multi-argument functions where a tuple argument is expected:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="Menlo">// #4: Works in Swift 3, error in Swift 4</font></div></div><div><div><span style="font-family:Menlo">_ = zip(array1, array2).map(+)</span></div></div></blockquote><div><br></div><div>In all of these cases, it is possible to write a closure that achieves the desired effect, but the result is more verbose and less intuitive:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="Menlo">// Works in both Swift 3 and Swift 4</font></div><div><font face="Menlo">myDictionary.forEach { element in</font></div></div><div><div><font face="Menlo"> let (key, value) = element</font></div></div><div><div><font face="Menlo"> print("\(key) -> \(value)")</font></div></div><div><div><font face="Menlo">}</font></div></div></blockquote><div><br></div><div>The Swift core team feels that these usability regressions are unacceptable for Swift 4. There are a number of promising solutions that would provide a better model for closures and address the usability regression, but fully designing and implementing those are out of scope for Swift 4. Therefore, we will “back out” the SE-0110 change regarding function arguments from Swift 4.</div><div><br></div><div>Specifically, when passing an argument value of function type (including closures) to a parameter of function type, a multi-parameter argument function can be passed to a parameter whose function type accepts a single tuple (whose tuple elements match the parameter types of the argument function). Practically speaking, all of the examples #1-#4 will be accepted in both Swift 3 and Swift 4.</div><div><br></div><div>We will revisit the design in this area post-Swift 4.</div><div><br></div><div><span class="m_3159248404073906172Apple-tab-span" style="white-space:pre-wrap">        </span>- Doug</div><div><br></div></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div><div dir="auto">Thank you :)</div><div dir="auto"><br></div><div dir="auto">--</div><div dir="auto">Víctor Pimentel</div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p style="font-family:Arial,sans-serif;font-size:13px;line-height:13px;margin:12px 0px"><span style="color:rgb(51,51,51);font-family:Helvetica,Arial,sans-serif;line-height:1em;display:block">
</span></p><p>
</p><p>
</p><div style="font-size:12.8px"><font size="1" face="arial narrow, sans-serif">D I G I T A L T E L C O E X P E R I E N C E</font></div><div style="font-size:12.8px"><font size="1" face="arial narrow, sans-serif"><br></font></div><div dir="ltr" style="font-size:12.8px"><div style="font-size:12.8px"><strong style="font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em;color:rgb(10,218,124)"><img src="cid:ii_1582527040132354" alt="Imágenes integradas 5"></strong></div></div><div dir="ltr" style="font-size:12.8px"><div style="font-size:12.8px"><strong style="font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em;color:rgb(10,218,124)"><br></strong></div><div style="font-size:12.8px"><strong style="font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em"><font color="#000000">Víctor Pimentel Rodríguez · </font></strong><span style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px">Principal iOS Engineer</span><br style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px"><a href="mailto:vpimentel@tuenti.com" style="color:rgb(32,141,206);font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em" target="_blank">vpimentel@tuenti.com</a><br style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px"><br style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px"><span style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em;display:block"><span style="font-family:Helvetica,Arial,sans-serif;font-size:11px;line-height:1em"><a href="javascript:void(0);" style="font-family:helvetica,arial,sans-serif;color:rgb(32,141,206)" target="_blank">+34 914 294 039</a> — <a href="javascript:void(0);" style="font-family:helvetica,arial,sans-serif;color:rgb(32,141,206)" target="_blank">+34 687 840 886</a><br>C/ Gran Vía, nº 28, 6ª planta — 28013 Madrid </span><br style="font-family:Helvetica,Arial,sans-serif"><span style="font-family:Helvetica,Arial,sans-serif;font-size:11px;line-height:1em">Tuenti Technologies, S.L.</span><br style="font-family:Helvetica,Arial,sans-serif"></span><span style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em;display:block"><span style="font-family:Helvetica,Arial,sans-serif;font-size:11px;line-height:1em"><br></span></span><span style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em;display:block"><a href="http://www.tu.com/" style="color:rgb(32,141,206);font-size:11px" target="_blank">www.tu.com</a><br></span><span style="color:rgb(51,51,51);font-family:helvetica,arial,sans-serif;font-size:13px;line-height:1em;display:block"><a href="http://www.tuenti.com/" style="color:rgb(32,141,206);font-size:11px" target="_blank">www.tuenti.com<br></a></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div>