<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="">Hi everybody,</div><div class=""><br class=""></div>I do agree with Kevin : trailing closures is only a possibility offered by the language, you are not forced to use it.<div class="">In the case you show, I agree that the second syntax is more readable than the first one. Good news is : it does compile :-).</div><div class=""><br class=""></div><div class="">I think adding a specific keyword or annotation to locally forbid trailing closure would add complexity to the language for no real advantage.</div><div class=""><br class=""></div><div class="">-1 for me thus.</div><div class=""><br class=""></div><div class="">Jerome<br class=""><div class=""><br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 04 Jan 2016, at 19:52, Kevin Ballard 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="">


<title class=""></title>

<div class=""><div class="">What's the point of this? What problem does it solve? If you don't want a trailing closure, just don't use trailing closure syntax. I don't see what benefit there is in explicitly annotating the function to disallow trailing closure syntax with it; just because you don't want to use trailing closure syntax doesn't mean nobody should be able to use it. And other people using it shouldn't affect you.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">-Kevin Ballard<br class=""></div>
<div class="">&nbsp;</div>
<div class="">On Mon, Jan 4, 2016, at 04:45 AM, QQ Mail via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">Hi, All:&nbsp;<br class=""></div>
<div class=""><span style="white-space:pre;" class=""></span>trailing closure is good for most cases, but sometimes it is also make code unclear, for example:&nbsp;<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(112, 61, 170)">UIView</span>.<span class="colour" style="color:rgb(61, 29, 129)">animateWithDuration</span>(<span class="colour" style="color:rgb(39, 42, 216)">0.3</span>, animations: { () -&gt; <span class="colour" style="color:rgb(112, 61, 170)">Void</span> <span class="colour" style="color:rgb(187, 44, 162)">in</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);" class=""><span class="colour" style=""></span>// animation code here<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class="">&nbsp; &nbsp; }) { (Bool) -&gt; <span class="colour" style="color:rgb(112, 61, 170)">Void</span> <span class="colour" style="color:rgb(187, 44, 162)">in</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);" class=""><span class="colour" style=""></span>// completion code here<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class="">}<br class=""></div>
</div>
<div class="">&nbsp;</div>
<div class="">the label been removed and the code also not aligned well.&nbsp;<br class=""></div>
<div class="">I would like to write like this:&nbsp;<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(61, 29, 129);" class=""><span class="colour" style="color:rgb(112, 61, 170)">UIView</span><span class="colour" style="">.</span>animateWithDuration<span class="colour" style="">(</span><span class="colour" style="color:rgb(39, 42, 216)">0.3</span><span class="colour" style="">,</span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class="">&nbsp; &nbsp; animations: { () -&gt; <span class="colour" style="color:rgb(112, 61, 170)">Void</span> <span class="colour" style="color:rgb(187, 44, 162)">in</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);" class=""><span class="colour" style=""></span>// animation code here<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class="">&nbsp; &nbsp; },<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class="">&nbsp; &nbsp; completion: { Bool -&gt; <span class="colour" style="color:rgb(112, 61, 170)">Void</span> <span class="colour" style="color:rgb(187, 44, 162)">in</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);" class=""><span class="colour" style=""></span>// completion code here<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class="">&nbsp; &nbsp; }<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class="">)<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;" class="">&nbsp;</div>
</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;" class="">It is possible, just every time you have to write it manually. It’s a little wast.<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;" class="">So I have a thought, since we already know this function is not well suit for trailing&nbsp;<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;" class="">closure, can we add a attribute to disable it, for example:&nbsp;<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;" class="">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;" class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;color:rgb(187, 44, 162);" class="">extension<span class="colour" style=""></span><span class="colour" style="color:rgb(112, 61, 170)">UIView</span><span class="colour" style=""> {</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;min-height:13px;" class="">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class=""><span class="colour" style="color:rgb(255, 40, 7)">@disable_trailing_closure</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class=""><span class="colour" style="color:rgb(187, 44, 162)">&nbsp; &nbsp; public</span> <span class="colour" style="color:rgb(187, 44, 162)">static</span> <span class="colour" style="color:rgb(187, 44, 162)">func</span> animateWithDuration(duration:<span class="colour" style="color:rgb(112, 61, 170)">NSTimeInterval</span>, animations:()-&gt;<span class="colour" style="color:rgb(112, 61, 170)">Void</span>, completion:()-&gt;<span class="colour" style="color:rgb(112, 61, 170)">Void</span>) {<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;color:rgb(0, 132, 0);" class=""><span class="colour" style=""></span>// implementations ...<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">&nbsp; &nbsp; }<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">}<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">I also found another one have issue for this too. link:&nbsp;<a href="http://www.natashatherobot.com/swift-trailing-closure-syntax/" class="">http://www.natashatherobot.com/swift-trailing-closure-syntax/</a><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">what do you think?<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">Best Regards<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">ChenYungui<br class=""></div>
</div>
<div class=""><img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-bottom:0px !important;margin-right:0px !important;margin-left:0px !important;padding-top:0px !important;padding-bottom:0px !important;padding-right:0px !important;padding-left:0px !important;" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/412c5a6d09663f8932538ffb032f477bf08ae0aeb363d1444052f4eb53353121/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e485235453667555f49584f68403577795e6948627d22364646656476565363556778737b6a6b65527857587f6d656249526a7f61336055725871644e6c4372497669557935387d2232435036573350587741733555485979727572484d223243715d22324d2232413c4b696a5b4863317e6f4b62584b694a6a49375d4a6a724973754172707145785434654d223246665466663a6e4a5a536b64777a43313759727a794372376a4266364234666830325e63664258716642583c6a4f49634f4178554e4a736a724378635935477d23344d23344/open" class=""><br class=""></div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div 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 class="">&nbsp;</div>

<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZfNDJ3c1KY40DpRPxaBpmw0PAd1TZW0h3lqFWlwcZNWjLV96dbtcrCsiPWnUeEjw6PthedwrtaabR9IDRv3eKTDAk0yEbNP9XkdRcWEJV2X-2BcrobzB7Ow0Mp0Bt7Wgx01iJOjhu1S5PWdIGdHrxb4vqEWdr8e-2BKRh3-2FgQfQqM-2BFFFR-2FgQTTJ6rDfnx5XXfnDur5GVMZsOYoEAbn7kECGtRlLJpUKUOHjlBLkIO4QEdY-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</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=""></div></div></div></body></html>