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

Chris Lattner clattner at nondot.org
Sat Nov 25 00:03:40 CST 2017


On Nov 24, 2017, at 9:20 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> Ok, so you just happened to pick a simple one:
> 
> Yup. Try to make a nominal type to describe labeled tuples.

People keep talking about adding integer values to generics, why not strings too? ;-)

>> what is the benefit of plumbing knowledge of metatypes through the entire generics system,
> 
> That’s not how one would implement this in the compiler. Most of the compiler doesn’t care whether the subject of a protocol conformance is a nominal type or not, and those scattered (but numerous) places that do care should be straightforward to generalize to include structural types. It’s not metatype-specific work.

Sure, I can buy that.  The thing that you’re leaving out is that you have to also generalize those (numerous) places to handle all the complexities of those non-nominal types.  The system has to handle keywords, inout arguments, etc somehow, and therefore the complexity to handle them needs to go somewhere.

The question is only whether one design or the other produces a lower energy state of complexity.  Given that I don’t know this code at all, if you think that your way is the best way to model it, then I’ll happily believe you. :-)

-Chris



More information about the swift-evolution mailing list