Tuples conform to Equatable

In a pre-release version of Swift, arbitrary rearrangement of labeled arguments was supported at call sites. This was removed in favor of a strict order by the time that Swift was released, except for labeled parameters with default arguments. This feature was ultimately removed in SE-0060.

Since tuples and argument lists were the same in prior versions of Swift, this meant that tuples have certain undocumented features required for argument lists, and not all of it has been removed. What you have discovered is an undocumented feature called "tuple shuffling." It has been proposed for removal:

The current state of tuples is summarized as follows:

As @rudkx has described, it is a fundamentally broken model:

...although it could be possible to fix what's broken without removing tuple shuffling:


As @Slava_Pestov has mentioned, functions used to be modeled as taking a single argument which might be a tuple, and moving away from this model has required a lot of work. Other examples of where Swift's new model isn't fully implemented are as follows:

  • Implicit tuple splatting was removed in SE-0029.
  • A distinction was made between functions that take a single tuple argument or multiple arguments in SE-0110, but to date this has not been completed implemented, because...
  • A "very narrow exception" was required for usability; the plan was to address this more holistically after Swift 4, but that has not yet been done.

  • Argument labels (unlike tuple element labels) no longer have type system significance due to SE-0111, but...
  • This causes a regression for closures that required mitigation, a multi-step plan that has not yet been completed.
5 Likes