<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>+1 from me as well to Tony's write-up.</div><div><br></div><div>-Thorsten&nbsp;</div><div><br>Am 26.04.2016 um 17:54 schrieb Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br><br></div><blockquote type="cite"><div><div style="white-space:pre-wrap">+1 to Tony's write-up.<br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 26, 2016 at 10:47 Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That seems like a purely syntactic concern that could potentially be addressed in other ways, though. I'm not sure the choice of "duplicate all operators using verbosely-named methods" is the best one for the reasons I mentioned above, and the question of "how do we cleanly unify operators with other protocol requirements?" seems&nbsp;out-of-scope and&nbsp;orthogonal to this proposal.<div><br></div><div>Given that we already have existing cases in the language where operators are declared within protocols (`Equatable` being the first one that comes to mind), I would recommend that this proposal follow that pattern for consistency and then the community continue a separate discussion about operators in protocols, which may or may not lead to changes across the entire language and standard library. The protocol operators discussion feels like a much larger topic that deserves to be discussed in its own right without bogging down the rest of this proposal.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 26, 2016 at 8:18 AM David Sweeris &lt;<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.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>I’m with Nicola on this one. Operators are currently odd in that they have to be declared globally. Everything else about protocol conformance is kept within the conforming type.</div><div><br></div><div>- Dave Sweeris</div></div><div style="word-wrap:break-word"><div><br></div><div><br></div><div><div><blockquote type="cite"><div>On Apr 26, 2016, at 9:28 AM, Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Apr 24, 2016 at 2:57 AM Nicola Salmoria via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&gt; &gt; func isEqual(to other: Self) -&gt;Bool<br>
&gt; &gt; func isLess(than other: Self) -&gt;Bool<br>
&gt; &gt; func isLessThanOrEqual(to other: Self) -&gt;Bool<br>
&gt;<br>
&gt; I'm still not sure why these are methods instead of operators.<br>
<br>
I think this is an *excellent* choice, and I hope it is the first step to completely removing operators from protocols.<br>
<br>
IMHO throwing operators into protocols is inconsistent and confusing. Having regular methods and a single generic version of the operator that calls down on the type’s methods is clearer and guarantees that generic code can avoid ambiguities by calling the methods directly, instead of having to rely only on heavily overloaded global operators.<br></blockquote><div><br></div><div>I personally disagree on this point. To me, a protocol describes a set of requirements for a type to fulfill, which includes things other than methods. Just as a protocol can define initializers, properties, and associated types that a type must define in order to conform, it makes sense that a protocol would also define which operators a conforming type must support.</div><div><br></div><div>Introducing a mapping between names and operators poses a few problems:</div><div><br></div><div>– IMO, they are overly verbose and add noise to the definition. This makes the language look less clean (I'm getting visions of NSDecimalNumber).</div><div>– They expose two ways to accomplish the same thing (writing `x.isEqual(to: y)` and `x == y`).</div><div>– Do certain operators automatically get mapped to method names with appropriate signatures across all types, or does a conforming type still have to provide that mapping by implementing the operators separately? If it's the latter, that's extra work for the author of the type writing the protocol. If it's the former, does it make sense to automatically push these operators for all types? Should any type that has an `add` method automatically get `+` as a synonym as well? That may not be desirable.</div><div><br></div><div>I'm very supportive of the floating-point protocol proposal in general, but I feel the arithmetic and comparison operations should be exposed by operators alone and not by methods, where there is a suitable operator that has the intended meaning.</div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">&nbsp;</span><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
—<br>
Nicola<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div>
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></blockquote></div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>
</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>