<br><div class="gmail_quote"><div dir="auto">On Sat, Sep 9, 2017 at 07:51 Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com">brent@architechies.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Sep 8, 2017, at 6:03 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_4157829467786687640Apple-interchange-newline"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote"><div>For any open protocol (i.e., a protocol for which the universe of possible conforming types cannot be enumerated a priori by the protocol designer) worthy of being a protocol by the Swift standard (&quot;what useful thing can you do with such a protocol that you could not without?&quot;), any sufficiently interesting requirement (i.e., one for which user ergonomics would measurably benefit from a default implementation) either cannot have a universally guaranteed correct implementation or has an implementation which is also going to be the most performant one (which can therefore be a non-overridable protocol extension method rather than an overridable protocol requirement with a default implementation). </div></div></div></div></div></blockquote><br></div></div><div style="word-wrap:break-word"><div>Counter-example: `index(of:)`, or rather, the underscored requirement underlying `index(of:)`. The &quot;loop over all indices and return the first whose element matches&quot; default implementation is universally guaranteed to be correct, but a collection like `Set` or `SortedArray` can provide an implementation which is more performant than the default.</div></div></blockquote><div dir="auto"><br></div><div dir="auto">Don&#39;t get me started on Swift&#39;s handling of equality and arrays with NaN. _customIndexOfEquatable, if I&#39;m not mistaken, is a part of that whole tangle of performance optimizations which gleefully refuse to acknowledge Equatable&#39;s semantic peephole for some values of a type being unordered with respect to everything else. In a world where this trade-off between performance and correctness had not been taken, I don&#39;t imagine that it would be possible to make the protocol extension method &#39;index(of:)&#39; any more performant than &#39;index(where: { $0 == $1 })&#39;.</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div></div></div></blockquote></div>