[swift-evolution] [Accepted] SE-0185 - Synthesizing Equatable and Hashable conformance
Chris Lattner
clattner at nondot.org
Thu Aug 17 12:04:32 CDT 2017
> On Aug 17, 2017, at 5:00 AM, Haravikk via swift-evolution <swift-evolution at swift.org> wrote:
>
>
>> On 17 Aug 2017, at 11:42, Robert Bennett <rltbennett at icloud.com <mailto:rltbennett at icloud.com>> wrote:
>>
>> Chris mentions that the intent was to mimic a default implementation in a constrained protocol extension, with one extension per type that doesn’t define its own ==/hashValue while conforming to Equatable/Hashable. Constrained extensions are allowed to use type information from the constraint, so I don’t think there is an issue here.
>
> And I disagree; this isn't a constraint extension either, not even close, we're talking here about automatic behaviour based upon variables the protocol knows literally nothing about, in a way that can result in new errors that are currently impossible (as you can't currently conform to Equatable without providing some kind of code to implement it).
I understand and recognize your concern. Your points are apply equally to the default implementation of the Codable protocols as well, and the core team specifically discussed this.
Also, if I were to nitpick your argument a bit, it isn’t true that the protocol knows “nothing" about the type anyway, because the protocol has access to self. The default implementation could conceptually use reflection to access all the state in the type: we’re producing the same effect with more efficient code.
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170817/38f00d04/attachment.html>
More information about the swift-evolution
mailing list