But we’re not reordering labels, we’re assigning to a different variable which has different variable names. And I think it should work because we are not using the restructuring syntax.
> On 5 May 2017, at 12:11, Adrian Zubarev <[email protected]> > wrote: > > I would assume the error is correct, because if we ban reordering than > labeled tuple types will become incompatible if the labels are swapped, > remember the strict order or labels. > > > > > -- > Adrian Zubarev > Sent with Airmail > > Am 5. Mai 2017 um 12:08:59, David Hart via swift-evolution > ([email protected] <mailto:[email protected]>) schrieb: > >> >> >> On 5 May 2017, at 10:59, Xiaodi Wu via swift-evolution >> <[email protected] <mailto:[email protected]>> wrote: >> >>> On Fri, May 5, 2017 at 03:11 André Videla <[email protected] >>> <mailto:[email protected]>> wrote: >>> >>> Just to make sure: >>> >>> let pair = (x: 3, y: 5) >>> Let swapped: (y: Int, x: Int) = pair >>> >>> Error. >> >> Why error here? In this case. It's not a label but he type. >> >>> Let (y: x1, x: y1) = pair >>> >>> Error. >>> >>> Let (x: x2, y: y2) = pair >>> >>> With the revised pitch that no longer prohibits all labels, x2 is 3 and y2 >>> is 5. In the original version, error. >>> >>> Let (x3, y3) = pair >>> >>> x3 is 3 and y3 is 5. >>> >>> After the change, What do (x_n, y_n) print and Which assignments are errors? >>> >>> Andre Videla >>> >>> On 5 May 2017, at 09:31, Xiaodi Wu via swift-evolution >>> <[email protected] <mailto:[email protected]>> wrote: >>> >>>> On Fri, May 5, 2017 at 2:28 AM, Adrian Zubarev >>>> <[email protected] <mailto:[email protected]>> >>>> wrote: >>>> I’m not arguing to remove all labels in Swift. Labels are great, this is a >>>> fact for sure. The point I was trying to make is that labels in tuples how >>>> either a meaning or not at all. >>>> >>>> // This is a shortcut for the tuple type `(x: Int, y: Int)` >>>> let foo = (x: 0, y: 0) >>>> >>>> // In this case the labels are only used for description, >>>> // they do not server any benefit here are most likely redundant >>>> let (x: x, y: y) = foo >>>> Labels elsewhere are a different story and I do support the cosmetic >>>> addition Chris Lattner sketched out here: >>>> https://lists.swift.org/pipermail/swift-evolution-announce/2016-July/000233.html >>>> >>>> <https://lists.swift.org/pipermail/swift-evolution-announce/2016-July/000233.html> >>>> However this is about closures and not tuples, I don’t think this would >>>> anyhow affect the removal of labels in tuple destructuring. >>>> >>>> Plus I don’t see this to create an inconsistent in Swift, because as I >>>> already said, labels in tuple destructuring are useless. >>>> >>>> How come? I just illustrated their use. They help humans write correct >>>> code by allowing the compiler to check an assertion that the human knows >>>> which labels go with which positions in the tuple. >>> >>>> _______________________________________________ >>> >>>> >>>> swift-evolution mailing list >>>> [email protected] <mailto:[email protected]> >>>> https://lists.swift.org/mailman/listinfo/swift-evolution >>>> <https://lists.swift.org/mailman/listinfo/swift-evolution> >>> _______________________________________________ >>> swift-evolution mailing list >>> [email protected] <mailto:[email protected]> >>> https://lists.swift.org/mailman/listinfo/swift-evolution >>> <https://lists.swift.org/mailman/listinfo/swift-evolution> >> _______________________________________________ >> swift-evolution mailing list >> [email protected] <mailto:[email protected]> >> https://lists.swift.org/mailman/listinfo/swift-evolution >> <https://lists.swift.org/mailman/listinfo/swift-evolution> >
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
