Would this proposed syntax, using argument labels, also be available in
function arguments?
e.g
func items(withCompletion completion(success:error:): ([Item]?, NSError?) ->
Void) {
...
completion(success: items, error:nil)
}
> On 22 Feb 2017, at 08:49, Charlie Monroe via swift-evolution
> <[email protected]> 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
>> <[email protected]> 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
>>> <[email protected]> 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
>>> [email protected]
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> _______________________________________________
>> swift-evolution mailing list
>> [email protected]
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution