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

Susan Cheng susan.doggie at gmail.com
Tue Jun 6 21:15:47 CDT 2017


Introduction

Because the painful of SE-0110, here is a proposal to clarify the tuple
syntax.

Proposed solution
1. single element tuple always be flattened

let tuple1: (((Int))) = 0  // TypeOf(tuple1) == Int


let tuple2: ((((Int))), Int) = (0, 0)  // TypeOf(tuple2) == (Int, Int)

2. function arguments list also consider as a tuple, which means the
function that accept a single tuple should always be flattened.

let fn1: (Int, Int) -> Void = { _, _ in }


let fn2: ((Int, Int)) -> Void = { _, _ in }  // always flattened

let fn3: (Int, Int) -> Void = { _ in }  // not allowed, here are two
arguments

let fn4: ((Int, Int)) -> Void = { _ in }  // not allowed, here are two
arguments
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170607/3e6704ba/attachment.html>


More information about the swift-evolution mailing list