<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="">This is an unfortunate side effect of another important and necessary change: Making argument labels part of functions name. This means that closures (which are&nbsp;anonymous functions and lack a function name) now don’t have any place to keep the argument labels.&nbsp;<div class=""><br class=""></div><div class=""><div class="">Using a labeled tuple as a single argument block could act as a workaround for now, but:</div></div><div class=""><br class=""></div><div class="">I think we really need to find the correct way to add back argument labels for closures. I strongly suspect such a change will be ABI breaking.</div><div class=""><br class=""></div><div class="">People (including myself) are getting some experience with actual implications and feel of lack of argument labels for anonymous functions. As far as I can tell, nobody likes this and it feels so very un-Swifty and a big step backwards.</div><div class=""><br class=""></div><div class="">Lets find a way to add back argument labels to closures for Swift 4.</div><div class=""><div class=""><br class=""></div><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Oct 16, 2016, at 3:33 PM, Grant Kemp 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=""><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">Hi all</span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">A South African in London here and I have decided to make the jump to trying to help </span><span class="inbox-inbox-lG" style="background-color:rgba(251,246,167,0.498039);outline:transparent dashed 1px;color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap">Swift</span><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class=""> develop. </span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">I was an android and web developer and </span><span class="inbox-inbox-lG" style="background-color:rgba(251,246,167,0.498039);outline:transparent dashed 1px;color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap">swift</span><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class=""> converted me to iOS programming which has become something that I love. I have built several apps on iOS and on macOS using it and thoroughly enjoyed it. </span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">One think has made me fall a little out of love with </span><span class="inbox-inbox-lG" style="background-color:rgba(251,246,167,0.498039);outline:transparent dashed 1px;color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap">swift</span><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class=""> 3 was the&nbsp;removal of </span><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">completion handler argument labels </span><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">which has created:</span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">1. Less maintainable code for teams </span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">2. Less readable  and thus more error prone code </span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">3. Slower code to write as now I have to regularly scroll to the top of the method to find out what the parameters should be . </span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">4. Seems to be at odds with other parts of the api which favours labels. </span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><font color="#212121" face="helvetica neue, helvetica, arial, sans-serif" class=""><span style="white-space:pre-wrap" class="">I have found quite a lot of support from others via my stack overflow question here: </span></font><div class=""><font color="#212121" face="helvetica neue, helvetica, arial, sans-serif" class=""><span style="white-space:pre-wrap" class=""><a href="http://stackoverflow.com/questions/39613272/xcode-8-function-types-cannot-have-argument-label-breaking-my-build" class="">http://stackoverflow.com/questions/39613272/xcode-8-function-types-cannot-have-argument-label-breaking-my-build</a></span></font><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;white-space:pre-wrap"><br class="">Here is my suggestion:&nbsp;</div><div class="">Currently the Swift 3 version does not allow arguments in the completionhandler method, which is confusing and not very readable.</div><p class="inbox-inbox-p2"><span class="inbox-inbox-s1"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; </span></span><span class="inbox-inbox-s2">func</span><span class="inbox-inbox-s1"> myMethod(</span><span class="inbox-inbox-s2">_</span><span class="inbox-inbox-s1"> completionhandler:(</span><span class="inbox-inbox-s2">_</span><span class="inbox-inbox-s1"> downloadedValue:</span><span class="inbox-inbox-s3">String</span><span class="inbox-inbox-s1">,</span><span class="inbox-inbox-s2">_</span><span class="inbox-inbox-s1"> isActive:</span><span class="inbox-inbox-s3">Bool</span><span class="inbox-inbox-s1">, </span><span class="inbox-inbox-s2">_</span><span class="inbox-inbox-s1"> error:</span><span class="inbox-inbox-s3">NSError</span><span class="inbox-inbox-s1">)-&gt; </span><span class="inbox-inbox-s3">Void</span><span class="inbox-inbox-s1">) {<br class=""></span><span class="inbox-inbox-s4"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></span><span class="inbox-inbox-s1">//&lt;&lt;After doing some async method such as downloading from an API &gt;&gt;</span></p><p class="inbox-inbox-p2"><span class="inbox-inbox-s1"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp; </span>completionhandler(myString, </span><span class="inbox-inbox-s2">true</span><span class="inbox-inbox-s1">, myError)</span></p><p class="inbox-inbox-p2"><span class="inbox-inbox-s1"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; </span>}<br class=""></span><span class="inbox-inbox-s4"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp;&nbsp;</span></span><span class="inbox-inbox-s1">// INSTEAD: ideally the argument labels should be added optionally to be called in the completion method such as below and using a Tuple-like syntax to indicate that the method should have the labels</span></p><p class="inbox-inbox-p2"><span class="inbox-inbox-s1"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; </span></span><span class="inbox-inbox-s2">func</span><span class="inbox-inbox-s1"> myMethod(</span><span class="inbox-inbox-s2">_</span><span class="inbox-inbox-s1"> completionhandler:( downloadedValue:</span><span class="inbox-inbox-s3">String</span><span class="inbox-inbox-s1">, isActive:</span><span class="inbox-inbox-s3">Bool</span><span class="inbox-inbox-s1">,<span class="inbox-inbox-Apple-converted-space">&nbsp; </span>error:</span><span class="inbox-inbox-s3">NSError</span><span class="inbox-inbox-s1">)-&gt; </span><span class="inbox-inbox-s3">Void</span><span class="inbox-inbox-s1">) {</span></p><p class="inbox-inbox-p3"><span class="inbox-inbox-s4"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></span><span class="inbox-inbox-s1">//&lt;&lt;After doing some async method such as downloading from an API &gt;&gt;</span><br class=""></p><p class="inbox-inbox-p2"><span class="inbox-inbox-s1"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp; </span>completionhandler(dowloadedValue:myString, isActive:</span><span class="inbox-inbox-s2">true</span><span class="inbox-inbox-s1">, error:myError)</span></p><p class="inbox-inbox-p2"><span class="inbox-inbox-s1"><span class="inbox-inbox-Apple-converted-space">&nbsp; &nbsp; </span>}</span></p><p class="inbox-inbox-p2"><span class="inbox-inbox-s1"><br class=""></span></p><div class=""><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">Thanks for the help ( and any feedback on my idea above ) </span><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><br class="gmail_msg" style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap"><span style="color:rgb(33,33,33);font-family:&quot;helvetica neue&quot;,helvetica,arial,sans-serif;font-size:13px;white-space:pre-wrap" class="">Thanks for the epic work you are doing ! </span><br class=""></div></div><div dir="ltr" class="">-- <br class=""></div><div data-smartmail="gmail_signature" class=""><div dir="ltr" class="">Sent from my mobile </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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>