<div dir="ltr">At the moment I&#39;m considering Jordan&#39;s point: &quot;<span style="font-size:13px">(IIRC last time we got to &quot;it&#39;s required if the member is in the same module, but allowed to be absent otherwise&quot;, which is fairly reasonable but probably still needs to be thought through.)&quot;</span><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Taking my example: Int, Int16, Int32, Int64 etc. conform to IntegerArithmeticType, so they have the operator `func + (lhs:Self, rhs:Self) -&gt; Self`. Double and Float have this function but there&#39;s no shared protocol, so I write my own `Summable` protocol and extend the existing types to conform to it.</span></div><div><span style="font-size:13px"><br></span></div><div>Is there a need for a counterpart keyword to &#39;implements&#39;: &#39;retroactive&#39;? I don&#39;t think so; I could declare my protocol with &#39;retroactive protocol Summable&#39; and then write my own custom Decimal type which conforms to Summable (and then uses &#39;implements func + (lhs: Decimal, rhs: Decimal) -&gt; Decimal&#39;) and I don&#39;t know if I&#39;ve gained anything from it.</div><div><br></div><div>I think perhaps &#39;@implements&#39; could be a useful attribute? Not actually required by the compiler, but a useful signifier while reading code. And if, during the course of a project&#39;s development, a function is removed from a protocol, the compiler could warn that an @implements function isn&#39;t actually required by any protocol the implementing type claims to conform to.</div><div><span style="font-size:13px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 19, 2016 at 1:14 AM, Victor Gao via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><br><blockquote type="cite"><div>Begin forwarded message:</div><br><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>From: </b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif">Victor Gao &lt;<a href="mailto:victorgao44@gmail.com" target="_blank">victorgao44@gmail.com</a>&gt;<br></span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>Subject: </b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif"><b>Re: [swift-evolution] [swift evolution] [proposal] Proposal to add &quot;implement&quot; keyword to denote protocol method implementation</b><br></span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>Date: </b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif">March 18, 2016 at 21:48:53 ADT<br></span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>To: </b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif">Ross O&#39;Brien &lt;<a href="mailto:narrativium+swift@gmail.com" target="_blank">narrativium+swift@gmail.com</a>&gt;<br></span></div><div><div class="h5"><br><div><div>Hi Ross,<br><br>That’s a good point actually, your point about retroactive modeling.<br><br>Correct me if I’m wrong, but what you are saying is that if you have a class that has some methods, and then you decided to create a protocol that has the methods of the class. If you want the class to conform to the protocol, you want to be able to do so without having to add the “implement” keyword in front of every method implementation. Is that right?<br><br>I also understand that one of the problems with the “implement” keyword: when you create an extension that adds a protocol conformance to a class,  if that the class already has the methods defined in the protocol, it wouldn’t work because the methods in the class don’t have the “implement” keyword! This is a perplexing problem. <br><br>Victor Gao<br><br><br><blockquote type="cite">On Mar 18, 2016, at 21:11, Ross O&#39;Brien &lt;<a href="mailto:narrativium+swift@gmail.com" target="_blank">narrativium+swift@gmail.com</a>&gt; wrote:<br><br>I recently had the misfortune of deleting what turned out to be a necessary function, because it was an optional requirement of a protocol and wasn&#39;t being called by any code in the project, so I would sympathise with this.<br><br>On the other hand I&#39;ve also written protocols composed entirely of functions that an established type already has, so I can retroactively have the type conform. (For example, there&#39;s no &#39;ArithmeticOperation&#39; protocol which Int and Double both conform to, even though they both have a `+ (lhs:Self, rhs:Self) -&gt; Self` operator, so you have to roll your own... unless that should be a proposal itself.) It would be impossible to require a function to use your &#39;implements&#39; keyword to conform to a protocol in an importing module.<br><br></blockquote><br></div></div></div></div></blockquote></div><br></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div>