Deprecating Tuple Shuffles (Round 2)

+1 for removing this feature.

Speaking only as a user of the language, I can say I did not know this feature existed, I do not see a benefit in it, and the inconsistency with the standard library's definition of tuple equality is a major problem.

I agree with @DevAndArtist that some facility of unordered destructuring is valuable, but I think all the times I've done this has been with what the proposal calls "Re-assignment through a tuple pattern", which is a non-example.

Some other form of destructuring assignment might be nice but that's a separate topic.

+1 for removing more inconsistencies.

Great news on this front. Though the bots have been a bit wonky lately, I turned on the Swift 5 mode behavior that produces an error on encountering a Tuple Shuffle in all Swift versions. Even under that configuration, the compatibility suite passed.

I've amended the proposal here and on Github to mention this, and I'm going to update my pull request to pull out my probes shortly. Because of the wonkiness I still haven't gotten a clean pass (for what I suspect are unrelated reasons), but I have gotten each of Debug and Release suites to pass independently and cannot reproduce the current set of source compatibility "failures" locally. I will at least make sure that it passes clean if/when it gets merged.

9 Likes

Is this saying that we could potentially just remove this behavior full stop, and not just in Swift 5 mode? Because I don't know of anyone who will miss this.

I'm hoping that with some of these poorly implemented "features" going away and ABI landing soon, we can start revisiting some of the features that were removed because the implementation was done poorly (I'm looking at you, curry syntax.)

5 Likes

Purely from an implementor's perspective, getting the green light from the core team to remove this from Swift 4(.2) would unlock a ton of cleanup all across the compiler stack (I highlight this briefly in the proposal draft).

There is a clear migration path that we could provide for the few people using this - just compute an inverse tuple shuffle and offer a fixit.

16 Likes

Great, thanks. Sounds ready to go to review then, especially since nobody seems to have raised any major concerns so far.

Edit: Skimming the older proposal thread, I think you've addressed the concerns people had back then. @xwu, you posted a lot in the previous thread so I'm mentioning you here in case you haven't seen the updated version.

Said it before, saying it again: removing this behavior from the language will allow what I consider the proper use of the phrase "tuple shuffle" to indicate code that uses tuple ordering to reassign values without intermediate variables or swap functions. :slight_smile:

let (value1, value2, value3) = (value2, value3, value1)
8 Likes

Is that not something more akin to Tuple deconstruction? The use of parens instead of curly braces is unfortunate.

I have to admit that when I first heard of Tuple shuffle I thought about Tuple deconstruction.

1 Like

@tkremenek @codafi Can we get this reviewed for Swift 5?

4 Likes

I think the ship has sailed for landing this in Swift 5, but we should still consider adding a change that unconditionally emits a warning. I suspect nobody is using this feature intentionally, and if nobody complains about the warning, we could rip it out in a future release.

9 Likes

+1!

1 Like

If that's the solution we wind up going with, I've got a branch at the ready.

8 Likes

Can you submit this to master and swift-5.0-branch, except change the wording of the diagnostic to not promise anything about future versions of Swift? Just say that shuffling is deprecated maybe

1 Like