[swift-evolution] Proposal: Always flatten the single element tuple

Gwendal Roué gwendal.roue at gmail.com
Thu Jun 8 13:38:35 CDT 2017


> Le 8 juin 2017 à 19:40, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> a écrit :
> 
>> On Jun 7, 2017, at 3:03 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Well please no:
>> 
>> 
>>  let fn2: ((Int, Int)) -> Void = { lhs, rhs in } 
>> 
>> Instead use destructuring sugar pitched by Chris Lattner on the other thread:
>> 
>> let fn2: ((Int, Int)) -> Void = { ((lhs, rhs)) in }
>> 
> 
> I think this suggestion is better than the status quo. I'm wondering, though, if we should just drop the outer set of parentheses entirely, unless you're also putting types on the parameters. That is, a closure of type `(Int, Int) -> T` can look like this:
> 
> 	{ (x: Int, y: Int) in … }
> 
> Or it can look like this:
> 
> 	{ x, y in … }
> 
> But it *cannot* look like this:
> 
> 	{ (x, y) in … }
> 
> The `(x, y)` form can instead be a closure of a type like `((Int, Int)) -> T`, which immediately destructures the tuple parameter into separate constants.

I better understand your message. It does look good at first sight.

But... The full picture needs to be completed with closures of type `((Int, Int)) -> T` and `((lsh: Int, rhs: Int)) -> T`. Those are among the most *interesting* in the regressions they brought.

Will there be any forbidden syntax as well? What about unfitted signatures, which I talked just before?

Gwendal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170608/6b795b0e/attachment.html>


More information about the swift-evolution mailing list