<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 Apr 13, 2017, at 2:42 PM, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Looking good. A few comments inline:</div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class="">On 13 Apr 2017, at 22:17, Ben Cohen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div class=""><h3 id="L-code-comparable--code-" class="" style="color: rgb(17, 17, 17); margin: 21px 0px; font-size: 20px; line-height: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;"><code class="" style="line-height: 1;">Comparable</code></h3><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">Comparable will be changed to have a new ternary comparison method:&nbsp;<code class="" style="line-height: 1;">compare(_ other: Self) -&gt; ComparisonResult</code>.&nbsp;<code class="" style="line-height: 1;">x.compare(y)</code>&nbsp;specifies where to place x relative to y. So if it yields&nbsp;<code class="" style="line-height: 1;">.orderedAscending</code>, then x comes before y. This will be considered the new “main” dispatch point of Comparable that implementors should provide.</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">Most code will continue to use&nbsp;<code class="" style="line-height: 1;">&lt;</code>&nbsp;or&nbsp;<code class="" style="line-height: 1;">==</code>, as it will be optimal for their purposes. However code that needs to make a three-way branch on comparison can use the potentially more efficient&nbsp;<code class="" style="line-height: 1;">compare</code>. Note that&nbsp;<code class="" style="line-height: 1;">compare</code>&nbsp;is only expected to be more efficient in this specific case. If a two-way branch is all that’s being done,&nbsp;<code class="" style="line-height: 1;">&lt;</code>&nbsp;will be more efficient in many cases (if only because it’s easier for the optimizer).</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">For backwards compatibility reasons,&nbsp;<code class="" style="line-height: 1;">compare</code>&nbsp;will have a default implementation defined in terms of&nbsp;<code class="" style="line-height: 1;">&lt;</code>, but to enable only using&nbsp;<code class="" style="line-height: 1;">compare</code>,&nbsp;<code class="" style="line-height: 1;">&lt;</code>&nbsp;and&nbsp;<code class="" style="line-height: 1;">==</code>&nbsp;will also have default implementations in terms of&nbsp;<code class="" style="line-height: 1;">compare</code>.</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">The compiler will verify that either&nbsp;<code class="" style="line-height: 1;">compare</code>, or&nbsp;<code class="" style="line-height: 1;">&lt;</code>&nbsp;and&nbsp;<code class="" style="line-height: 1;">==</code>, are provided by every type that claims to conform to&nbsp;<code class="" style="line-height: 1;">Comparable</code>. This will be done in some unspecified way unavailable outside the standard library (it can be made available to in the future, but that’s an unnecessary distraction for this proposal).</p></div></div></div></div></blockquote><div class="">It feels weird to me to jump through all these hoops just for backwards compatibility. Seeing how even big projects might only have several Comparable conformances, wouldn’t it be worth removing the default implementation of compare and removing &lt; from Comparable?</div></div></div></blockquote><br class=""></div><div>The core team cares a *lot* about backwards compatibility. The engineering effort involved in implementing this mutually-exclusive check is very small compared with the benefits of maintaining compatibility.</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div><br class=""></div><br class=""></body></html>