[swift-evolution] [Review] Tuple comparison operators (was: Add a Lazy flatMap for Sequences of Optionals)

Tino Heth 2th at gmx.de
Wed Dec 23 06:03:16 CST 2015

> The justification for making Tuples comparable pretty much consists of hand-waving.
> Why should (0,3,4) be smaller than (0,5,0)? Beats me.
> Why would it be the other way around? Also beats me.

I strongly agree that comparison for tuples makes little sense - but I'd choose a different example:
(0, 1) < (1, Any.self)
Both are tuples, they are not equal - but can you bring them into a natural order?
"Yeah, but those aren't tuple of the same type, of course you have to have exact same types for comparison"
Right, but when you want to use tuples of the same type in different places, wouldn't it be better to declare that type officially?

If tuple comparison comes for free: So be it — but I can't see any good use cases for this feature.
Of course, as Objective-C has no tuples, we don't have that much experience with them, but my expectation is that in most cases where order of tuples matters, it will depend on a single member — and there shouldn't be pressure to choose the order of the members just to get comparison for free.


More information about the swift-evolution mailing list