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

Xiaodi Wu xiaodi.wu at gmail.com
Fri May 5 02:20:26 CDT 2017

On Fri, May 5, 2017 at 2:04 AM, Adrian Zubarev <
adrian.zubarev at devandartist.com> wrote:

> Personally I don’t see the latter as an issue, at least not in that
> particular example of yours, because you can always look up the type of
> your labeled tuple.
That's an argument that can be made for nearly all labels in the language,
is it not? Function argument labels could be entirely removed, by your
argument, since parameter names are completely visible in the documentation
and you can always just look it up. Consider the rationale behind revising
SE-0111 expressly to allow "cosmetic" labels. As I said, many languages
don't have labels, but Swift does.

> Is there any benefit gained from labels in tuple destructuring? let (x:
> x, y: y) is redundant to my eyes. If we ban reordering now, than I don’t
> see choosing different names in tuple destructuring as a strong argument of
> allowing labels there let (x: a, y: b). They’re literally the same as one
> would write comments inside the destructured tuple let (/* my x */ x, /*
> my y*/ y).
If you look in the C++ parts of the Swift compiler, that's the style for
arguments in function calls where in Swift we use argument labels. Same
idea. Your argument would remove most if not all labels from the language.

> --
> Adrian Zubarev
> Sent with Airmail
> Am 5. Mai 2017 um 08:36:20, Xiaodi Wu via swift-evolution (
> swift-evolution at swift.org) schrieb:
> ```
> let tuple = (x: 1, y: 2)
> // I, silly human, mistakenly think the elements in the tuple are
> // `y` first, then `x`. I'm a confused human. Now I write:
> let (y: y, x: x) = tuple
> // Currently, does the right thing, even though I'm confused.
> let (y: y, x: x) = tuple
> // Without tuple reordering, this produces an error, which corrects my
> confusion.
> let (y, x) = tuple
> // Oops. I'm out of luck.
> ```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170505/b661f310/attachment.html>

More information about the swift-evolution mailing list