<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Agreed.<div class=""><br class=""></div><div class="">In the property behaviors review, Chris Lattner mentioned that there is a trend to use # to denote compiler synthesis. Thus, this is probably a good alternative.<br class=""><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Patrick</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 13, 2016, at 4:37 PM, Developer <<a href="mailto:devteam.codafi@gmail.com" class="">devteam.codafi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">I'd be in favor of forgoing the keyword addition and just prefixing compiler-derivable protocols with a # or @. Save `deriving` for later extensions to a future generalized deriving mechanism.<br class=""><br class="">~Robert Widmann</div><div class=""><br class="">2016/02/13 16:29、Patrick Gili via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> のメッセージ:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class="">I've been playing with the concept in Haskell, and I like the concept. However, I don't like the proposed syntax, as it is not consistent the rest of the language. Maybe something like<div class=""><br class=""></div><div class="">struct Person : deriving Equatable {</div><div class=""> let age: Int</div><div class=""> let name: String</div><div class="">}</div><div class=""><br class=""></div><div class="">or </div><div class=""><br class=""></div><div class="">struct Person : @deriving Equatable {</div><div class=""> let age: Int</div><div class=""> let name: String</div><div class="">}</div><div class=""><br class=""></div><div class="">-Patrick</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 13, 2016, at 12:38 PM, Donald Pinckney <<a href="mailto:djpinckney@ucdavis.edu" class="">djpinckney@ucdavis.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">To make sure I understand correctly, what you are discussing is having == be auto generated in some way for types. The automatic implementation of == would be a member wise logical and operation:</div><div class=""><br class=""></div><div class="">struct Person {</div><div class=""> let age: Int</div><div class=""> let name: String</div><div class="">} deriving Equatable</div><div class=""><br class=""></div><div class="">Would also generate:</div><div class="">func ==(left: Person, right: Person) -> Bool {</div><div class=""> return left.age == right.age && left.name == right.name;</div><div class="">}</div><div class=""><br class=""></div><div class="">The compiler would only do this if all data members implement (or derive) the Equatable protocol, and probably error otherwise.</div><div class=""><br class=""></div><div class="">That's my interpretation. If I misunderstood, please correct me. </div><div class=""><br class=""></div><div class="">As it stands, I think something like this is a fabulous idea, as I have recently found myself writing lots of member wise equality checks.</div><div class=""><br class=""><div class="">Donald Pinckney</div><div class=""><br class=""></div>Sent from my iPhone</div><div class=""><br class="">On Feb 13, 2016, at 9:12 AM, Donnacha Oisín Kidney via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class="">In Haskell, when you declare a datatype, you can follow it with a “deriving” clause, and it will derive several typeclasses (which are Haskell’s equivalent to protocols):<div class=""><br class=""></div><div class=""><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">data</span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Person</span><span style="font-family: Menlo; font-size: 11px;" class=""> = </span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Person</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(49, 44, 221); font-family: Menlo; font-size: 11px;" class="">{</span><span style="font-family: Menlo; font-size: 11px;" class=""> name </span><span style="color: rgb(49, 44, 221); font-family: Menlo; font-size: 11px;" class="">::</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">String</span><span style="color: rgb(49, 44, 221); font-family: Menlo; font-size: 11px;" class="">,</span><span style="font-family: Menlo; font-size: 11px;" class=""> age </span><span style="color: rgb(49, 44, 221); font-family: Menlo; font-size: 11px;" class="">::</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(49, 44, 221); font-family: Menlo; font-size: 11px;" class="">}</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">deriving</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Eq</span></div><div class=""><br class=""></div><div class="">In Swift, I’d imaging the equivalent would be something like:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> Person {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> name: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> age: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">} deriving <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Equatable</span></div></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 13 Feb 2016, at 17:04, Patrick Gili via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Not having a lot of experience with Haskell, can you provide an example, so that we can better understand what you're proposing?<br class=""><br class="">Cheers,<br class="">-Patrick<br class=""><br class=""><blockquote type="cite" class="">On Feb 12, 2016, at 3:47 PM, Daniel Tartaglia via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">In Haskell, we can mark a data block as deriving from Eq and it will auto-generate the == operator.<br class=""><br class="">I would like to see Swift auto-generate the == operator if a struct implements Equatable. Obviously, it would only be able to do this if all the structs members implemented Equatable themselves.<br class=""><br class="">Has this idea already been proposed? I didn’t see it at the github repo…<br class=""><br class="">Thanks,<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></div></body></html>