<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div>Charlie Monroe wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">This hasn't occurred to me until now, but this will also elminate the following (right?):<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">typealias</span><span style="font-variant-ligatures: no-common-ligatures" class=""> XUURLRequestModifier = (request: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSMutableURLRequest</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span></div></div><div style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class="">Which is really nice since when expanded by Xcode, this automatically offers you the "request" label for the variable so you don't have to name it.</div></div></blockquote><br><div>As far as I understood, no it won't eliminate that use case, and quite the contrary this is exactly the cosmetic change to the original proposal that the core team wanted to add. So your code above will work, but with the change that a closure `modifier` of type `XUURLRequestModifier` is called like `modifier(req)` from now on and not `modifier(request: req)`.</div><div><br></div><div>I think it's often missed in this discussion that there are not one but *two* cases where argument labels (or the lack of them) matter in Swift, and both of cases also affect auto-completion:</div><div><br></div><div>1) The first case is when calling a closure (which most often was passed to the current function as an argument). What the accepted proposal SE-0111 did was remove argument labels from those calls in all circumstances:</div><div><br></div><div> func modifyRequest(modifier: XUURLRequestModifier) {</div><div> // This autocompletes without labels as something like:</div><div> modifier(<#request#>)</div><div> // I.e. the cosmetic labels still appear as placeholders, AFAICT.</div><div> }</div><div><br></div><div>Most of the time, the code that calls a closure is written once and run multiple times with various blocks, so simple mistakes that argument types won't catch get easily catched in unit tests or when testing the application.</div><div><br></div><div>2) The second, and much more common case in application-level code IMO is when passing a closure argument to a library function:</div><div><br></div><div> // This, I think, would autocomplete as:</div><div> frob.modifyRequest { (request: NSMutableURLRequest) -> Void in</div><div> // I.e. now the cosmetic label becomes the default argument name.</div><div> }</div><div><br></div><div>So this is where cosmetic labels matter most and nothing changed in this regard in the outcome of SE-0111.</div><div><br></div><div>* * *</div><div><br></div><div>For people longing to pass labels when *calling* closures, I think you should consider proposing the extended naming syntax idea (or some variant) where an N-argument closure can alternatively be bound to a name with N labels (see <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md">https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md</a>):</div><div><br></div><div> // This closure is named `modify(request:)`</div><div> let modify(request:): XUURLModifierRequest = { request in</div><div> ...</div><div> }</div><div> modify(request: req)</div><div><br></div><div> // The argument with label `modifier` is *locally* named `mod(req:)`.</div><div> func example(modifier mod(req:): XUURLModifierRequest) {</div><div> mod(req: someRequest)</div><div> }</div><div><br></div><div> example { request in ... }</div><div> example(modifier: modify(request:))</div><div><br></div><div>Note that the local name `req(mod:)` wouldn't need to match the call site (except in type), and they really shouldn't either.</div><div><br></div><div>— Pyry</div></body></html>