[swift-evolution] Proposal: Implement == and < for tuples where possible, up to some high arity

Chris Lattner clattner at apple.com
Mon Dec 7 18:09:31 CST 2015


> On Dec 7, 2015, at 4:08 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> 
>> 
>> On the contrary, I think >4-element-tuples are useful exactly *for* the case
>> of custom structs. You wouldn't want the tuples themselves to be part of
>> your API, but if you have a custom struct with 4+ Comparable fields, you can
>> implement its < operator as simply "return (a1,b1,c1,d1,e1) <
>> (a2,b2,c2,d2,e2)”.
>> 
>> 
>> Sure, or:
>>   return (a1,b1,(c1,d1,e1)) < (a2,b2,(c2,d2,e2))
> 
> That won't work, since tuples don't conform to Comparable.

Ah right, someone should really fix that :-) :-)

-Chris


More information about the swift-evolution mailing list