<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 2, 2017, at 4:22 PM, Xiaodi Wu via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Thu, Nov 2, 2017 at 5:22 PM, Matthew Johnson <span dir="ltr" class=""><<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>></span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><br class=""><div class=""><blockquote type="cite" class=""><span class="gmail-"><div class="">On Nov 2, 2017, at 5:20 PM, Jonathan Hull via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank" class="">swift-dev@swift.org</a>> wrote:</div><br class="gmail-m_9196866851710290294Apple-interchange-newline"></span><div class=""><div style="overflow-wrap: break-word;" class=""><span class="gmail-">It looks like we have a good solution. Per Steve and David’s suggestions:<div class=""><br class=""></div><div class="">1) Make FloatingPoint == reflexive</div><div class=""><br class=""></div><div class="">2) Add &== to FloatingPoint for those who specifically want IEEE behavior</div><div class=""><br class=""></div><div class="">3) Add a warning + fixit to ‘a != a’ </div><div class=""><br class=""></div></span><div class="">We should take this to evolution…</div></div></div></blockquote><div class=""><br class=""></div>Looks like a winner to me.</div></div></blockquote><div class=""><br class=""></div><div class="">Again, there remain several problems with this design. In the concrete context, the syntax `&==` suggests that it is a compatibility, legacy, or specialized function not to be preferred over `==`. This makes Swift deviate from every other programming language, creating a new footgun for experienced developers, and encourages a performance hit where one is not demonstrably necessary (most operations that ask about UI coordinates, say, will never have NaN as an input). Again also, this design eliminates the possibility of writing a class of useful algorithms that use Numeric. It also doesn't address the problem of sorting (as NaN would still compare unordered to all other values). These are serious questions that require careful consideration.<br class=""></div><div class=""><br class=""></div><div class="">In initiating this conversation, my goal has been to start a conversation about possible designs for `Equatable` and `Comparable` that permis useful generic algorithms to work correctly with floating point without hampering performance or changing syntax for concrete numerics. Unless this is clearly impossible, the leap of changing the behavior of `==` for a numeric type should absolutely not be the proposed solution, in my view.<br class=""></div></div></div></div></div></blockquote><br class=""></div><div>What about bringing `===` into the mix? IIRC `identity`semantics aren't well-defined for value types anyway. Is there even an "Identifiable" protocol in the stdlib?</div><div><br class=""></div><div>- Dave Sweeris</div><br class=""></body></html>