[swift-evolution] Argument labels in callbacks

Goffredo Marocchi panajev at gmail.com
Wed Feb 22 03:04:51 CST 2017


I remember it and remember the disagreements over this simplification too, but I really hope this is now not skipping a full year again.

Sent from my iPhone

> On 22 Feb 2017, at 08:49, Charlie Monroe <charlie at charliemonroe.net> wrote:
> 
> This was pointed out during the discussions surrounding this proposal and it was agreed that the type simplification was important.
> 
> There were several suggestions how to bring this back using different features - e.g. compound names that would contain the labels. For example:
> 
> let callback(success:error:): (Bool, Error?) -> Void = ...
> callback(success: true, error: nil)
> 
> This way the type itself wouldn't contain the label information, but the name of the variable would.
> 
>> On Feb 22, 2017, at 9:41 AM, Goffredo Marocchi via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> I am quite interested in this as well, thanks for bringing it up! It was quite disappointing to fall back to multi argument method calls without labels as it was going against the emphasis on the value of labels in the language as well as decreasing readability of what is supposed to be self documenting code.
>> 
>> Sent from my iPhone
>> 
>>> On 22 Feb 2017, at 08:36, Franklin Schrans via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> Hi,
>>> 
>>> When SE-0111 was approved, I noticed the implication it had when using closures as callbacks:
>>> 
>>> Writing
>>>    func foo(completion: (success: Bool) -> Void) {
>>>      completion(success: true)
>>>    }
>>> 
>>> is no longer possible, because function types can’t have argument labels anymore, and the function has to be written:
>>>    func foo(completion: (Bool) -> Void) {
>>>      completion(true)
>>>    }
>>> 
>>> which doesn’t look very nice, especially as the number of the arguments increases.
>>> 
>>> After talking to Chris Lattner about this, he referred me to this email.
>>> I was wondering if there's been any further work or plans in restoring the use of argument labels in closures.
>>> 
>>> - Franklin
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170222/9f74bee6/attachment.html>


More information about the swift-evolution mailing list