<div style="white-space:pre-wrap">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. </div><br><div class="gmail_quote"><div dir="ltr">On Sat, Oct 15, 2016 at 09:28 Haravikk via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg">
> On 15 Oct 2016, at 16:04, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> 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.<br class="gmail_msg">
><br class="gmail_msg">
> 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.<br class="gmail_msg">
<br class="gmail_msg">
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).<br class="gmail_msg">
<br class="gmail_msg">
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.<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>