[swift-evolution] [Proposal] Explicit Synthetic Behaviour

Gwendal Roué gwendal.roue at gmail.com
Tue Sep 12 10:47:33 CDT 2017


> Le 12 sept. 2017 à 17:26, Tony Allevato <tony.allevato at gmail.com> a écrit :
> 
> Since your game involves the specific question of a property that should not be considered for Equatable synthesis, and since SE-0185 explicitly calls out the notion of transient properties as a future direction to solve that specific problem, then my solution is "I declare the property as transient."
> 
> Surely this is an acceptable solution? It achieves the goal you set, and more concisely/quickly than the ways you proposed in that post. It doesn't require me to go fishing through code; the act of adding the property and making it transient is completely localized to one place (it's one line!). If there's a synthesized implementation of Equatable, then the property gets ignored as desired. If there's a handwritten implementation, then the new property is already ignored because it wasn't there to begin with, but the transient declaration still provides valuable information to the reader of the code about the intention.
> 
> If the rebuttal to that is going to be "a developer may not know about transient", then where do we draw the line at expecting users to know how to use the features their language? It's a significant leap to go from "developers might do the wrong thing" to "so this specific approach is the only right way to fix it."

Your answer is totally valid in a world where properties can be declared transient.

So you may now be aware that in a world where there are no transient properties, implicit synthesis of Equatable and Hashable conformance has problems that explicit synthesis has not. Making more people aware of this is my only goal in this thread.

Gwendal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170912/d8a3d0f5/attachment.html>


More information about the swift-evolution mailing list