<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Your proposition makes comparison code much less readable only for a small benefit at the point of definition. I'd vote against.</div><div><br>On 08 Dec 2015, at 11:06, Nicky Gerritsen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>
  
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  
  
    Although I like the idea, I think it should be more general, as this
    same reasoning also holds for other operators.<br>
    Wouldn't it be better to allow to define operators within a type? So
    that we can just implement == in the type?<br>
    <br>
    I do not know how hard it is to implement it or if this is even
    possible. Probably it is hard, because otherwise it would already
    have been done?<br>
    <pre class="moz-signature" cols="72">Regards,

Nicky</pre>
    <div class="moz-cite-prefix">On 12/08/2015 11:01 AM, Richard Fox via
      swift-evolution wrote:<br>
    </div>
    <blockquote cite="mid:CAKK64=ggLQwCsSBH9MBzoQ5KJP=Vbgs0yNV6EazDJ0h6WByO5Q@mail.gmail.com" type="cite">
      <div dir="ltr">
        <h3 style="margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI
          Symbol';margin-top:0px!important"><span style="font-size:16px;line-height:25.6px;font-weight:normal">Hi
            all,</span><br>
        </h3>
        <p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI
          Symbol';font-size:16px;line-height:25.6px">I would like to
          propose changing the Equatable protocol to use&nbsp;<code style="font-family:Consolas,'Liberation
            Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0.2em
0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">isEqual(to:Self)
            -&gt; Bool</code>, defined inside of a type to replace the
          currently used operator&nbsp;<code style="font-family:Consolas,'Liberation
            Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0.2em
0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">==</code>&nbsp;function,
          which is defined outside of the type.</p>
        <h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><a moz-do-not-send="true" id="user-content-reasoning" class="anchor" href="https://gist.github.com/Nadohs/308603afa65cbbfba07c#reasoning" style="color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1.2;background-color:transparent"><span class="octicon octicon-link" style="font-weight:normal;font-stretch:normal;font-size:16px;line-height:1;font-family:octicons;display:inline-block;color:rgb(0,0,0);vertical-align:middle"></span></a>Reasoning:</h3>
        <ol style="padding:0px 0px 0px
          2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI
          Symbol';font-size:16px;line-height:25.6px">
          <li style="box-sizing: border-box;">Having the conforming
            function defined inside of the type is more intuitive, since
            in general functions required for conformance are defined
            within the type. It feels like an unnecesary detail for
            learners of Swift to have to stumble through.</li>
        </ol>
        <p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI
          Symbol';font-size:16px;line-height:25.6px">The implementation
          for this would look something like this:</p>
        <pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(247,247,247)"><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0px;margin:0px;border-radius:3px;word-break:normal;border:0px;display:inline;max-width:initial;overflow:initial;line-height:inherit;word-wrap:normal;background:transparent">     public protocol Equatable{
       ....

       /// Shortcut for defining `==` function inside type definition.
       @warn_unused_result
       func isEqual(to:Self) -&gt; Bool
     }

     @warn_unused_result
     public func == &lt;T : Equatable&gt;(lhs: T, rhs: T) -&gt; Bool {
         return lhs.isEqual(rhs)
     }
</code></pre>
        <h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><a moz-do-not-send="true" id="user-content-impact-on-existing-code" class="anchor" href="https://gist.github.com/Nadohs/308603afa65cbbfba07c#impact-on-existing-code" style="color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1.2;background-color:transparent"><span class="octicon octicon-link" style="font-weight:normal;font-stretch:normal;font-size:16px;line-height:1;font-family:octicons;display:inline-block;color:rgb(0,0,0);vertical-align:middle"></span></a>Impact
          on Existing Code:</h3>
        <p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI
          Symbol';font-size:16px;line-height:25.6px">This implementation
          would break existing code, but could be fixed with a default
          protocol extension such as:</p>
        <pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(247,247,247)"><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0px;margin:0px;border-radius:3px;word-break:normal;border:0px;display:inline;max-width:initial;overflow:initial;line-height:inherit;word-wrap:normal;background:transparent">     /// Default `isEqual` function to satisfy other types only definiting
     /// `==` for equality.
     public extension Equatable{
         func isEqual(to:Self) -&gt; Bool{
             return self == to
         }
     }  
</code></pre>
        <p style="margin-top:0px;color:rgb(51,51,51);font-family:'Helvetica
          Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple
          Color Emoji','Segoe UI Emoji','Segoe UI
          Symbol';font-size:16px;line-height:25.6px;margin-bottom:0px!important">Not
          adding the default function for&nbsp;<code style="font-family:Consolas,'Liberation
            Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0.2em
0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">isEqual</code>&nbsp;makes
          more sense to me though, since it would remove any strict
          requirement for Equatable conformance and leave no warning for
          the loop you would create by implementing neither&nbsp;<code style="font-family:Consolas,'Liberation
            Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0.2em
0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">isEqual</code>&nbsp;nor&nbsp;<code style="font-family:Consolas,'Liberation
            Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0.2em
0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">==</code>.<br>
          <br>
          Regards,<br>
          Rich Fox</p>
      </div>
      <img moz-do-not-send="true" src="https://u2002410.ct.sendgrid.net/wf/open?upn=RHl2la-2BftHBRgU0PDt5l8enF-2FEQjC5JypuWCzFZiX9RFxTQ-2BMiLiXWVDri-2FqZ9JkpZYRyntAD5jDorctLW3ieg6VPkteLjD3FEN-2FKRo0WrLD1wpmOa7FzqmnIGlfXAu5ENo5Rp7dwXhSjXq5AfIMpfKl5LKljZaicWmxHb5T87j-2Bt-2BSsySAGP4rHwB5kkwh4Iux3jWEmK2pYJ9qD29vNPE6rw-2FxjVTQrk2SE3ZsGXZ4-3D" alt="" style="height:1px !important;width:1px
        !important;border-width:0 !important;margin-top:0
        !important;margin-bottom:0 !important;margin-right:0
        !important;margin-left:0 !important;padding-top:0
        !important;padding-bottom:0 !important;padding-right:0
        !important;padding-left:0 !important;" height="1" width="1" border="0">
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
swift-evolution mailing list
<a class="moz-txt-link-abbreviated" href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>
<a class="moz-txt-link-freetext" href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a>
</pre>
    </blockquote>
    <br>
  
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43hXwizS3O2z60WweqomIrdiby1oM0uSRtxZF1S8eVPCcMS3Ztj9I1zTsCG3bdH5TePR-2Ft5S8biBvfes30cYJ3yuc0ADzxg1xjwSEmgCtnIEv09AUXvmtMVBEC5cyVAYAUuYHrD-2BkLrorXL-2Fd3bPYUSJ0qlOrhZTW2263yhLyxV9F6IaXf87TehxIgJFkIqpFvA-3D-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">



</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>