[swift-evolution] Synthesizing Equatable, Hashable, and Comparable for tuple types

David Sweeris davesweeris at mac.com
Sat Nov 25 16:29:37 CST 2017


> On Nov 25, 2017, at 08:05, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Sat, Nov 25, 2017 at 06:35 Mike Kluev <mike.kluev at gmail.com> wrote:
>>> On 25 November 2017 at 03:12, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>> 
>>>> On Fri, Nov 24, 2017 at 9:08 PM, Mike Kluev via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>>>> On 24 November 2017 at 23:47, Douglas Gregor <dgregor at apple.com> wrote:
>>>> 
>>>>> 
>>>>> e.g., making all tuples of Equatable elements Equatable 
>>>> 
>>>> that's already the case.. (all tuples of equatable elements are equatable). no?
>>> 
>>> No, tuples do not conform to any protocols. There are hardcoded implementations of `==` up to some arity in the stdlib to partially mitigate the lack of protocol conformance.
>> 
>> to me as a user the end result is the same...
>> probably we need a better convincing example of what users may want that doesn't have a workaround now.
> 
> The workaround substantially bloats the standard library, and the result is nothing close to the same because your type is still not Equatable. This means that it cannot benefit from any generic algorithms. For example, an array of such tuples cannot be Equatable in turn.
> 
>> speaking of ugliness, the ellipsis on the left of names is quite ugly:
>> 
>>      extension<...Elements : Equatable> (Elements...) : Equatable
> 
> Seems perfectly fine to me.

Agreed.

Speaking of which, have we started designing the syntax & semantics of the variadic generics/tuples system yet? I’ve been away from my computer a lot lately, and I tend to miss threads when subject lines gets truncated to “[swift-evolution][pitch] Some subj” on my phone.

- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171125/ebd67513/attachment.html>


More information about the swift-evolution mailing list