If you're looking for a use case for tuple equality, I often pack a bunch of values in a tuple and check it with another, which makes it easy to compare a multiple values at once and perform something only if all of them are equal.
On Sat, Oct 15, 2016 at 09:28 Haravikk via swift-evolution < firstname.lastname@example.org> wrote: > > > On 15 Oct 2016, at 16:04, Xiaodi Wu <xiaodi...@gmail.com> wrote: > > > > Yes it absolutely matters what the types are. Two floating point values > can compare equal when their raw bytes differ and they can compare not > equal even when their raw bytes are the same, and it would be absolutely > necessary that a tuple of two floating point values behaves the same way. > > > > Moreover, if a value is not equatable, it's nonsense to ask if tuples of > two of them are equal. Otherwise, you've effectively forced every value > type to be equatable, since it'd be ridiculous if (a, a) == (b, b) didn't > imply a == b. > > All I meant really is that you can always compare equality at the memory > level, regardless of Equatable conformance; the type checker ensures the > tuples being compared can only contain the same types in the same order, at > which point a bitwise memory comparison can determine they are equal in the > strictest possible sense, much like comparing whether two object references > point to the same object (you're comparing the pointers). > > But actually it doesn't seem to even matter; tuples are already Equatable > if all of their components are (again, something I don't seem to actually > use), so that should be more than sufficient for using them as enum raw > values, we can just ignore tuples that aren't/require the developer to add > Equatable to any components that aren't. > _______________________________________________ > swift-evolution mailing list > email@example.com > https://lists.swift.org/mailman/listinfo/swift-evolution >
_______________________________________________ swift-evolution mailing list firstname.lastname@example.org https://lists.swift.org/mailman/listinfo/swift-evolution