<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=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class="">I think the feature should stay but we need community guidelines on when and when not to use them.</div></blockquote><br class=""></div><div class="">I agree with James here.</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 1:15 PM, James Campbell 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="">I think the feature should stay but we need community guidelines on when and when not to use them.</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Head Of CEO</b></p><p class=""><b class=""><font color="#cc0000" class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Mar 24, 2016 at 4:13 PM, William Dillon via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 7:18 AM, Kurt Werle via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">Coming from ruby, I'm quite fond of trailing closures.&nbsp; I couldn't really give you a concrete reason why - putting them in the ()'s really isn't that big a deal.&nbsp; But I'll say that I move them outside every single time...<div class=""><br class=""></div><div class="">I will say that your examples are the most trivial possible and that the more complex the closure (describing context variables and return types, throws, etc) the uglier it seem to me to put it inside parens.</div></div><div class="gmail_extra"><br class=""></div></div></blockquote></div><br class=""></span><div class="">Agree.</div><div class=""><br class=""></div><div class="">Another thing I like about trailing closures is that it allows me to make custom constructs that feel more like a part of the language.&nbsp; For example, I really love this extension for NSLock that I have:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code';color:rgb(4,51,255)" class=""><span class="">extension</span><span style="" class=""> </span><span style="color:#3495af" class="">NSLock</span><span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">&nbsp; &nbsp; </span><span style="color:#0433ff" class="">func</span><span class=""> protect(action: (</span><span style="color:#3495af" class="">Void</span><span class="">) -&gt; </span><span style="color:#3495af" class="">Void</span><span class="">) {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#0433ff" class="">self</span><span class="">.</span><span style="color:#3495af" class="">lock</span><span class="">()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; action()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#0433ff" class="">self</span><span class="">.</span><span style="color:#3495af" class="">unlock</span><span class="">()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">&nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">}</span></div></div><div class=""><span class=""><br class=""></span></div><div class=""><span class="">Now, whenever I need to use my lock, I can just do:</span></div><div class=""><span class=""><br class=""></span></div><div class=""><span class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code';color:rgb(52,149,175)" class=""><div style="margin:0px;line-height:normal" class=""><span class="">peersLock</span><span style="" class="">.</span><span class="">protect</span><span style="" class=""> {</span></div><div style="margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; outputString += </span><span style="color:#b4261a" class="">"</span><span class="">\</span><span style="color:#b4261a" class="">(</span><span style="color:#0433ff" class="">self</span><span class="">.</span><span class="">peers</span><span class="">.</span><span class="">count</span><span style="color:#b4261a" class="">) peers:\n"</span></div><div style="margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; </span><span style="color:#0433ff" class="">for</span><span class=""> (</span><span style="color:#0433ff" class="">_</span><span class="">, peer) </span><span style="color:#0433ff" class="">in</span><span class=""> </span><span style="color:#0433ff" class="">self</span><span class="">.</span><span class="">peers</span><span class=""> {</span></div><div style="margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; outputString += </span><span style="color:#b4261a" class="">"</span><span class="">\</span><span style="color:#b4261a" class="">(</span><span class="">peer</span><span style="color:#b4261a" class="">)\n"</span></div><div style="margin:0px;line-height:normal" class=""><div style="font-family: Helvetica; font-size: 12px;" class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">&nbsp; &nbsp;&nbsp;}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Code'" class=""><span class="">}</span></div><div class=""><span class=""><br class=""></span></div></div></div><div class=""><span class="">To me, it looks cleaner to me to not have this paren dangling around at the end.&nbsp; On this one I’d definitely say that if you don’t like it, don’t use it.&nbsp; I don’t *think* that you’re forced to use it anywhere.&nbsp; It’s a hard sell to take it away from everyone.</span></div><div class=""><span class=""><br class=""></span></div><div class=""><span class="">- Will</span></div></div></span></div></div><br class="">_______________________________________________<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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br 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=""></body></html>