[swift-evolution] Tuple

Vladimir.S svabox at gmail.com
Thu Jul 21 06:50:36 CDT 2016

On 21.07.2016 12:33, Fabian Ehrentraud via swift-evolution wrote:
>> It's error by design: we don't allow tuple unpacking in closure parameters. Another example:
>> func call(block: ((Int, Int)) -> Int)  // note double parens
>> call { (a, b) in print(a + b) }  // will be error
>> call { (a) in print(a.0 + a.1) } // ok
> Is there a reason for this design, or would it be possible / make sense to support this?

I believe because there is a question: is `(a,b)` is a list of two 
parameters or unpacked tuple? The closure definition requires one tuple 

But probably such syntax could be used to define unpacked tuple in parameters :
call { ((a, b)) in print(a + b) }  // note double parens

this feels consistent with tuple definition ((Int, Int)), the question here 
is if such syntax is not-confusing and is clear about arguments.

In any case this is additive feature, so we should discuss it after Swift 3.0

>  F
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list