[swift-evolution] [Proposal][Discussion] Deprecate Tuple Shuffles

Adrian Zubarev adrian.zubarev at devandartist.com
Fri May 5 00:52:31 CDT 2017


Eliminating all labels would mean that even the first example from my last post will be banned.

Is there any difference from labels in tuple types and labels in tuples themselves?

Personally I would not support the removal of labels from tuple types, because it’s a very useful feature that replaces indexed access like myTuple.1 to a more readable counterpart myTuple.somethingSpecial.

Am I still missing something out?



-- 
Adrian Zubarev
Sent with Airmail

Am 5. Mai 2017 um 07:43:49, Xiaodi Wu (xiaodi.wu at gmail.com) schrieb:

On Fri, May 5, 2017 at 12:42 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
Okay now I see where this is going. So basically you want to mirror the behavior of function parameters into tuples.

You might want to be a little bit more explicit on types in your proposal to better understand the so called ‘tuple shuffle’.

let a: (x: Int, y: Int) = (x: 1, y: 2)
var b: (y: Int, x: Int) = a
a.x == b.x
a.y == b.y
Label swap (tuple shuffle) while destructuring:

let tuple: (first: Int, second: (x: Int, y: Int)) = (first: 0, second: (x: 1, y: 2))

let (first: a, second: (x: b, y: c)): (first: Int, second: (x: Int, y: Int)) = tuple // fine, unaffected

let (second: (x: b, y: c), first: a): (second: (x: Int, y: Int), first: Int) = tuple // shuffle => error

No, I thought this was what Robert was proposing, but he is proposing the elimination of all labels in tuple patterns. Your second example would be banned.

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


More information about the swift-evolution mailing list