On 13.09.2017 17:13, Haravikk via swift-evolution wrote:

Well, certainly, synthesized default implementations differ from non-synthesized ones in key respects. However, they do not differ in terms of the user experience of conforming to the protocol and having to override the default.

Except that that's not true at all, is it?

Synthesised default implementations go much further in how they attempt (and potentially fail) to implement those defaults, and in the specific case of Equatable/Hashable they are fully implementing a protocol without a single property of method being raised as a requirement; they are utterly different at a fundamental level, no amount of mental contortion changes that fact.

FWIW Fully agree with Haravikk. Just want to add my 2 cents. We hear an opinion that protocol with auto-synthesization of requirements should be treated as a normal protocol with deault implenentation. So, this is just a variant of default implementation.

Actually I can agree with this. *BUT.* Such a *well-declared* protocol, which uses macros/reflection/other to access *type's fields* to implement the default methods IMO should also be explicitly conformed with 'deriving'-like keyword to be able to synthesize methods. For example, as first thoughts, such protocol should be marked with some kind of @synthesizable directive and probably have some helpers in this case from compiler to implement synthesizable defaults. Yes, one probably can implement protocol which uses macros/reflection without @synthesizable directive for protocol, but this should be considered as not-well-formed protocol.

Vladimir.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to