Equatable, where the == operator is defined, will not let you compare two things of a different type. <br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 15, 2016 at 10:02 Johannes Neubauer &lt;<a href="mailto:neubauer@kingsware.de">neubauer@kingsware.de</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
&gt; Am 15.07.2016 um 18:41 schrieb Johannes Neubauer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;:<br>
&gt;<br>
&gt;<br>
&gt;&gt; Am 15.07.2016 um 18:29 schrieb Saagar Jha &lt;<a href="mailto:saagarjha28@gmail.com" target="_blank">saagarjha28@gmail.com</a>&gt;:<br>
&gt;&gt;<br>
&gt;&gt; Here&#39;s a value type that uses custom equality (at least, I think so): String. Since it uses extended grapheme clusters, internally two Strings may be composed of different Unicode scalars, but if they create the same Characters they are considered to be equal.<br>
&gt;<br>
&gt; Good point. But shouldn’t this be another type of equality then or do they behave exactly the same and are just implemented differently? Because if not, this seems to be introducing mixed-type comparisons like `5l == 5` or `Point2D(0, 0) == Point3D(0, 0, 0) which are bad since they make it impossible to guarantee reflexivity, symmetry, and transitivity. Swift does a hard job to enforce this from the programmer. If this is really intended, then there should be a fixed implementation for equality of value types, which can be overridden, but which leads to a warning (which has to be suppressed with some kind of annotation or so). Because, these custom implementations can do harm.<br>
<br>
And I would do the „standard equality“ upfront even if there is a custom implementation and if the „standard equality“ says `true`, the custom implementation is not asked. This would reduce the possibility of false-negatives.<br>
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">-Saagar Jha</div></div>