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

Adrian Zubarev adrian.zubarev at devandartist.com
Wed Jun 7 05:34:44 CDT 2017

Well I’m clearly against this, it doesn’t hurt to use some more paeans inside a closure to tell the compiler if you want to destructure a tuple or use a single argument for the whole tuple.

Adrian Zubarev
Sent with Airmail

Am 7. Juni 2017 um 12:31:47, Susan Cheng (susan.doggie at gmail.com) schrieb:

`((Int, Int)) -> Void` will be same type as `(Int, Int) -> Void`

2017-06-07 18:09 GMT+08:00 Adrian Zubarev <adrian.zubarev at devandartist.com>:
Keep in mind there is also SE–0111 cometary which promises sugar for parameter labels for closures:

// **
let foo(tuple:): ((Int, Int)) -> Void

// Sugar for **
let foo: (tuple: (Int, Int)) -> Void
What will happen if you’d always flatten here?

Adrian Zubarev
Sent with Airmail

Am 7. Juni 2017 um 12:03:08, Adrian Zubarev (adrian.zubarev at devandartist.com) schrieb:

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 }

That’s a correct error:

let fn3: (Int, Int) -> Void = { _ in }
This should be allowed, because we might want to work with the whole tuple and not a desctructured elements only:

let fn4: ((Int, Int)) -> Void = { tuple in }

Adrian Zubarev
Sent with Airmail

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170607/15337aa9/attachment.html>

More information about the swift-evolution mailing list