<div dir="ltr">Since the first public betas I’d like to know why operator implementation have to be written outside the body of its owner.<div><br></div><div>Take as example the code:</div><div><br></div><div><p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)"><span style="color:rgb(116,137,31)">protocol</span> MyEquatable {</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(116,137,31)"><span style="color:rgb(80,111,116)">    </span>@warn_unused_result</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">func</span> ==(lhs: <span style="color:rgb(215,96,27)">Self</span>, rhs: <span style="color:rgb(215,96,27)">Self</span>) -&gt; <span style="color:rgb(251,153,3)">Bool</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">}</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116);min-height:17px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)"><span style="color:rgb(116,137,31)">struct</span> MyStruct: <span style="color:rgb(18,101,182)">MyEquatable</span> {</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">let</span> foo: <span style="color:rgb(251,153,3)">String</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">let</span> bar: <span style="color:rgb(251,153,3)">String</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">}</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116);min-height:17px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)"><span style="color:rgb(116,137,31)">func</span> ==(lhs: <span style="color:rgb(255,147,0)">MyStruct</span>, rhs: <span style="color:rgb(255,147,0)">MyStruct</span>) -&gt; <span style="color:rgb(251,153,3)">Bool</span> {</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">return</span> lhs.<span style="color:rgb(14,123,195)">foo</span> == rhs.<span style="color:rgb(14,123,195)">foo</span> &amp;&amp; lhs.<span style="color:rgb(14,123,195)">bar</span> == rhs.<span style="color:rgb(14,123,195)">bar</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">}</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116);min-height:17px"><br></p></div><div>Why we cannot write:</div><div><br></div><div><p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)"><span style="color:rgb(116,137,31)">protocol</span> MyEquatable {</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(116,137,31)"><span style="color:rgb(80,111,116)">    </span>@warn_unused_result</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">func</span> ==(lhs: <span style="color:rgb(215,96,27)">Self</span>, rhs: <span style="color:rgb(215,96,27)">Self</span>) -&gt; <span style="color:rgb(251,153,3)">Bool</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">}</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116);min-height:17px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)"><span style="color:rgb(116,137,31)">struct</span> MyStruct: <span style="color:rgb(18,101,182)">MyEquatable</span> {</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">let</span> foo: <span style="color:rgb(251,153,3)">String</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">let</span> bar: <span style="color:rgb(251,153,3)">String</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116);min-height:17px">    </p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    <span style="color:rgb(116,137,31)">func</span> ==(lhs: <span style="color:rgb(255,147,0)">MyStruct</span>, rhs: <span style="color:rgb(255,147,0)">MyStruct</span>) -&gt; Bool {</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">        <span style="color:rgb(116,137,31)">return</span> lhs.foo == rhs.foo &amp;&amp; lhs.bar == rhs.bar</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">    }</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116);min-height:17px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116)">}</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Input Mono&#39;;color:rgb(80,111,116);min-height:17px"><br></p></div><div>Any thoughts?</div><div><br></div><div><br></div><div>-Van</div><div><br></div></div>