<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 class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: 'SF UI Text'; 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="">Saagar Jha</span><br style="color: rgb(0, 0, 0); font-family: 'SF UI Text'; 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;" class=""><br style="color: rgb(0, 0, 0); font-family: 'SF UI Text'; 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;" class=""><br style="color: rgb(0, 0, 0); font-family: 'SF UI Text'; 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;" class="">
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Jan 4, 2017, at 8:35 PM, Douglas Gregor &lt;<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: SFUIText-Regular; 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;" class=""><br class="Apple-interchange-newline">On Jan 4, 2017, at 7:48 PM, Saagar Jha via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" style="font-family: SFUIText-Regular; 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div class="">Check out&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160606/020470.html" class="">this thread</a>–it’s very similar to what you proposed, but it didn’t go anywhere. FWIW +1 to this as well as the ability to use multiple trailing closures like so:<div class=""><br class=""></div><div class="">animate(identifier: “”, duration: 0, update: {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>// update</div><div class="">}, completion: {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>// completion</div><div class="">}</div><div class=""><div class=""><br class="Apple-interchange-newline"><span class="" style="font-family: 'SF UI Text'; 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;">Saagar Jha</span><br class="" style="font-family: 'SF UI Text'; 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="" style="font-family: 'SF UI Text'; 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="" style="font-family: 'SF UI Text'; 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;"></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 4, 2017, at 6:25 PM, Jay Abbott via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper"><p class="" style="margin: 0px 0px 1.2em !important;">When you have a function with a closure and then another optional default<span class="Apple-converted-space">&nbsp;</span><code class="" style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; display: inline;">= nil</code><span class="Apple-converted-space">&nbsp;</span>closure at the end, like this:</p><pre class="" style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code class="language-swift hljs" style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 0px 0.15em; white-space: pre; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em; color: rgb(51, 51, 51); background-image: none; background-attachment: scroll; background-color: rgb(248, 248, 248); display: block !important; background-position: 0% 0%; background-repeat: repeat repeat;">open <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">static</span> <span class="hljs-func"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">func</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">animate</span><span class="hljs-params">(identifier: String,
                         duration: Double,
                         update: @escaping AnimationUpdate,
                         completion: AnimationCompletion? = <span class="hljs-built_in" style="color: rgb(0, 134, 179);">nil</span>)</span> </span>{
</code></pre><p class="" style="margin: 0px 0px 1.2em !important;">You can’t use trailing closure syntax for the<span class="Apple-converted-space">&nbsp;</span><code class="" style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; display: inline;">update</code><span class="Apple-converted-space">&nbsp;</span>argument when leaving the<span class="Apple-converted-space">&nbsp;</span><code class="" style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; display: inline;">completion</code><span class="Apple-converted-space">&nbsp;</span>argument out/default.</p><p class="" style="margin: 0px 0px 1.2em !important;">This kind of breaks one of the benefits of default arguments, which is that you can add them to existing released functions without breaking the calling code. This means you have to add a separate convenience function without the extra argument, which is annoying and inelegant.</p></div></div></div></blockquote></div></div></div></blockquote><div style="font-family: SFUIText-Regular; 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;" class="">Why not simply add the "completion" parameter before the trailing closure? That would still allow existing callers to work, without having to change the language.&nbsp;</div><br style="font-family: SFUIText-Regular; 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;" class=""><blockquote type="cite" style="font-family: SFUIText-Regular; 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper"><p class="" style="margin: 0px 0px 1.2em !important;">Another annoying thing is that you can easily miss this error if you happen to not use trailing closure syntax in your tests or other usage, because adding the extra default argument compiles fine for code that uses normal syntax.</p></div></div></div></blockquote></div></div></div></blockquote><div style="font-family: SFUIText-Regular; 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;" class="">The Swift compiler warns when a parameter written as a closure type isn't the last parameter. The warning is actually disabled in the specific case above because you've written it using a typealias... maybe we should warn on such cases (it's worth a bug report). Regardless, in the majority of instances, you'll get a warning, so it won't be silent on disabling trailing closure syntax.&nbsp;</div></div></blockquote><div><br class=""></div><div>Tried this out in the playground:</div><div><br class=""></div><div>func foo(a: () -&gt; (), b: (() -&gt; ())? = nil) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>a()</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>b?()</div><div>}</div><div><br class=""></div><div>foo(a: {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>print(“Bar”)</div><div>})</div><div><br class=""></div><div>and didn’t receive a warning for it, either.</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: SFUIText-Regular; 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;" class=""><blockquote type="cite" style="font-family: SFUIText-Regular; 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper"><p class="" style="margin: 0px 0px 1.2em !important;">Are there any issues/gotchas if the trailing closure syntax were to work for the last<span class="Apple-converted-space">&nbsp;</span><em class="">specified</em><span class="Apple-converted-space">&nbsp;</span>argument rather than the last<span class="Apple-converted-space">&nbsp;</span><em class="">defined</em>argument?</p></div></div></div></blockquote></div></div></div></blockquote><div style="font-family: SFUIText-Regular; 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;" class="">The main gotcha, and the reason the rule is the way it is, is that it means you'd lose trailing closure syntax if the caller wanted to specify an argument for the last parameter.</div><div style="font-family: SFUIText-Regular; 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;" class=""><br class=""></div><div style="font-family: SFUIText-Regular; 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;" class="">&nbsp; &nbsp;- Doug</div><div style="font-family: SFUIText-Regular; 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;" class=""><br class=""></div><br style="font-family: SFUIText-Regular; 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;" class=""><blockquote type="cite" style="font-family: SFUIText-Regular; 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper"><div title="MDH:PGRpdiBkaXI9Imx0ciIgY2xhc3M9ImdtYWlsX21zZyI+PGRpdiBjbGFzcz0iZ21haWxfbXNnIj48
ZGl2IGNsYXNzPSJnbWFpbF9tc2ciPjwvZGl2PldoZW4geW91IGhhdmUgYSBmdW5jdGlvbiB3aXRo
IGEgY2xvc3VyZSBhbmQgdGhlbiBhbm90aGVyIG9wdGlvbmFsIGRlZmF1bHQgYD0gbmlsYCBjbG9z
dXJlIGF0IHRoZSBlbmQsIGxpa2UgdGhpczo8YnIgY2xhc3M9ImdtYWlsX21zZyI+PC9kaXY+YGBg
c3dpZnQ8YnIgY2xhc3M9ImdtYWlsX21zZyI+b3BlbiBzdGF0aWMgZnVuYyBhbmltYXRlKGlkZW50
aWZpZXI6IFN0cmluZyw8YnIgY2xhc3M9ImdtYWlsX21zZyI+Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5i
c3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7
Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5i
c3A7Jm5ic3A7IGR1cmF0aW9uOiBEb3VibGUsPGJyIGNsYXNzPSJnbWFpbF9tc2ciPiZuYnNwOyZu
YnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNw
OyZuYnNwOyZuYnNwOyZuYnNwO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24g
d2l0aG91dCB0aGUgZXh0cmEgYXJndW1lbnQsIHdoaWNoIGlzIGFubm95aW5nIGFuZCBpbmVsZWdh
bnQuIEFub3RoZXIgYW5ub3lpbmcgdGhpbmcgaXMgdGhhdCB5b3UgY2FuIGVhc2lseSBtaXNzIHRo
aXMgZXJyb3IgaWYgeW91IGhhcHBlbiB0byBub3QgdXNlIHRyYWlsaW5nIGNsb3N1cmUgc3ludGF4
IGluIHlvdXIgdGVzdHMgb3Igb3RoZXIgdXNhZ2UsIGJlY2F1c2UgYWRkaW5nIHRoZSBleHRyYSBk
ZWZhdWx0IGFyZ3VtZW50IGNvbXBpbGVzIGZpbmUgZm9yIGNvZGUgdGhhdCB1c2VzIG5vcm1hbCBz
eW50YXguPGJyIGNsYXNzPSJnbWFpbF9tc2ciPjxiciBjbGFzcz0iZ21haWxfbXNnIj48L2Rpdj48
ZGl2IGNsYXNzPSJnbWFpbF9tc2ciPkFyZSB0aGVyZSBhbnkgaXNzdWVzL2dvdGNoYXMgaWYgdGhl
IHRyYWlsaW5nIGNsb3N1cmUgc3ludGF4IHdlcmUgdG8gd29yayBmb3IgdGhlIGxhc3QgKnNwZWNp
ZmllZCogYXJndW1lbnQgcmF0aGVyIHRoYW4gdGhlIGxhc3QgKmRlZmluZWQqIGFyZ3VtZW50Pzxi
ciBjbGFzcz0iZ21haWxfbXNnIj48L2Rpdj48L2Rpdj4=" class="" style="height: 0px; width: 0px; max-height: 0px; max-width: 0px; overflow: hidden; font-size: 0em; padding: 0px; margin: 0px;"></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><br class=""></div></blockquote></div><br class=""></div></div></blockquote><blockquote type="cite" style="font-family: SFUIText-Regular; 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div></blockquote></div><br class=""></body></html>