<div dir="ltr"><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)">Swift Evolution,</div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)">Swift's API Design Guidelines are really good in my opinion, but I believe there is </div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)">ambiguity with current trailing closure syntax.</div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)">Take for example if there were three variations of a `subscribe`function:</div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)">
<p class="gmail-p1"><span class="gmail-s1"> </span><span class="gmail-s2">func</span><span class="gmail-s1"> subscribe(onNext block: </span><span class="gmail-s2">@escaping</span><span class="gmail-s1"> (</span><span class="gmail-s3">Event</span><span class="gmail-s1">) -> </span><span class="gmail-s4">Void</span><span class="gmail-s1">) { ... }</span></p><p class="gmail-p1"><span class="gmail-s2"> func</span><span class="gmail-s1"> subscribe(onError block: </span><span class="gmail-s2">@escaping</span><span class="gmail-s1"> (</span><span class="gmail-s3">Event</span><span class="gmail-s1">) -> </span><span class="gmail-s4">Void</span><span class="gmail-s1">) { ... }</span></p><p class="gmail-p2"><span class="gmail-s1"></span></p>
<p class="gmail-p2"><span class="gmail-s2"> func</span><span class="gmail-s1"> subscribe(onCompleted block: </span><span class="gmail-s2">@escaping</span><span class="gmail-s1"> (</span><span class="gmail-s3">Event</span><span class="gmail-s1">) -> </span><span class="gmail-s4">Void</span><span class="gmail-s1">) { ... }</span><br><span class="gmail-s1"></span></p><p class="gmail-p2">Since using subscribe with trailing closure syntax would cause ambiguity:</p><p class="gmail-p2"> subscribe { event in ... } </p><p class="gmail-p2">The only option available is to call the function as normal:</p><p class="gmail-p2"> subscribe(onNext: { event in ... })</p><p class="gmail-p2">Since these functions are distinguished by their argument label, if a variation of trailing closure syntax were introduced that provided the option of using an argument label in parenthesis this ambiguity would disappear.</p><p class="gmail-p2">something like this:</p><p class="gmail-p2"> subscribe(onNext:) { event in ... }</p><p class="gmail-p2">would allow using trailing closure syntax in this case.</p><p class="gmail-p2">Just a thought, I personally think having this change to the language would be worthwhile but would love to hear the community's opinion. </p><p class="gmail-p2">- Nick <br></p><p class="gmail-p2"><br></p></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif;color:rgb(39,78,19)"><br></div></div>