<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>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></div>
<div>&nbsp;</div>
<div>-Kevin Ballard<br></div>
<div>&nbsp;</div>
<div>On Mon, Jan 4, 2016, at 04:45 AM, QQ Mail via swift-evolution wrote:<br></div>
<blockquote type="cite"><div>Hi, All:&nbsp;<br></div>
<div><span style="white-space:pre;"></span>trailing closure is good for most cases, but sometimes it is also make code unclear, for example:&nbsp;<br></div>
<div>&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;"><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></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);"><span class="colour" style="color:rgb(0, 0, 0)"></span>// animation code here<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">&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></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);"><span class="colour" style="color:rgb(0, 0, 0)"></span>// completion code here<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">}<br></div>
</div>
<div>&nbsp;</div>
<div>the label been removed and the code also not aligned well.&nbsp;<br></div>
<div>I would like to write like this:&nbsp;<br></div>
<div>&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;color:rgb(61, 29, 129);"><span class="colour" style="color:rgb(112, 61, 170)">UIView</span><span class="colour" style="color:rgb(0, 0, 0)">.</span>animateWithDuration<span class="colour" style="color:rgb(0, 0, 0)">(</span><span class="colour" style="color:rgb(39, 42, 216)">0.3</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><br></div>
<p 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;"><br></p><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">&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></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);"><span class="colour" style="color:rgb(0, 0, 0)"></span>// animation code here<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">&nbsp; &nbsp; },<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">&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></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);"><span class="colour" style="color:rgb(0, 0, 0)"></span>// completion code here<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">&nbsp; &nbsp; }<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">)<br></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;">&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;">It is possible, just every time you have to write it manually. It’s a little wast.<br></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;">So I have a thought, since we already know this function is not well suit for trailing&nbsp;<br></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;">closure, can we add a attribute to disable it, for example:&nbsp;<br></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;">&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;"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;color:rgb(187, 44, 162);">extension<span class="colour" style="color:rgb(0, 0, 0)"></span><span class="colour" style="color:rgb(112, 61, 170)">UIView</span><span class="colour" style="color:rgb(0, 0, 0)"> {</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;min-height:13px;">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;"><span class="colour" style="color:rgb(255, 40, 7)">@disable_trailing_closure</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;"><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></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;color:rgb(0, 132, 0);"><span class="colour" style="color:rgb(0, 0, 0)"></span>// implementations ...<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">&nbsp; &nbsp; }<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">}<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">I also found another one have issue for this too. link:&nbsp;<a href="http://www.natashatherobot.com/swift-trailing-closure-syntax/">http://www.natashatherobot.com/swift-trailing-closure-syntax/</a><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">what do you think?<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">Best Regards<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;">ChenYungui<br></div>
</div>
<div><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"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div>&nbsp;</div>
</body>
</html>