<div dir="ltr">On Fri, Jul 22, 2016 at 11:34 PM, Stephen Canon <span dir="ltr">&lt;<a href="mailto:scanon@apple.com" target="_blank">scanon@apple.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; The point of this design is that `===` means identity and that `.same `<br>
&gt; also means identity.<br>
&gt;<br>
&gt; Since this is new territory I suppose we get to decide what identity<br>
&gt; means for floating point.  Should +0 and -0 have the same identity or<br>
&gt; not?  I’ll leave the answer to folks more knowledgable about numerics<br>
&gt; than I.<br>
<br>
</span>Boy, I take my wife out for a movie and come back to 50 new messages on SE.<br>
<br>
I need to read the entire thread more carefully, but off the top of my head, I think that `-0 === +0` is False.  If we’re going to have an `isSame` / `isIdentical` / whatever it&#39;s called, I would expect it to imply substitutability.  Although -0 == +0, they are not equivalent when substituted:<br>
<br>
- 1/(-0) != 1/0<br>
- Float(-0).sign != Float(+0).sign<br>
- etc<br>
<br>
This probably then implies that `&lt;=&gt;` is not `.same` either.  I’ll read the rest of this and respond more completely tomorrow.<br></blockquote><div><br></div><div>Eagerly await your evaluation of the discussion. In the meantime:</div><div><br></div><div>I think Dave&#39;s view that `===` defines identity in terms of &quot;essential&quot; qualities implies that two identical values can be different/non-substitutable in &quot;inessential&quot; qualities. For generic purposes, the sign of zero could be one such inessential quality.</div><div><br></div><div>On the other hand, the stdlib stride algorithm is going to be borked if -0 &lt; +0. Of course, as we already started to do there, we could specialize for floating point and then adjust accordingly. However, it seems to me that every generic algorithm that performs comparisons and can take floating point arguments would have to be specialized to account for floating point -0 != +0 (`index(of:)` being the previous example). This appears to defeat the aim of trying to accommodate FP at all in this revised design for Comparables.</div><div><br></div><div>The argument for `-0 === +0` is that -0 and +0 should be equivalent when substituted for every comparison operation. For FP operations, you&#39;d continue to test (as you have to test now) `a == b &amp;&amp; a.sign == b.sign` if you cared about the sign of zero. For non-FP arithmetic operations, hmm, not sure how to square that circle.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
– Steve</blockquote></div><br></div></div>