<div dir="ltr">At the moment I'm considering Jordan's point: "<span style="font-size:13px">(IIRC last time we got to "it's required if the member is in the same module, but allowed to be absent otherwise", which is fairly reasonable but probably still needs to be thought through.)"</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) -> Self`. Double and Float have this function but there'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 'implements': 'retroactive'? I don't think so; I could declare my protocol with 'retroactive protocol Summable' and then write my own custom Decimal type which conforms to Summable (and then uses 'implements func + (lhs: Decimal, rhs: Decimal) -> Decimal') and I don't know if I've gained anything from it.</div><div><br></div><div>I think perhaps '@implements' 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's development, a function is removed from a protocol, the compiler could warn that an @implements function isn'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"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></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 <<a href="mailto:victorgao44@gmail.com" target="_blank">victorgao44@gmail.com</a>><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 "implement" 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'Brien <<a href="mailto:narrativium+swift@gmail.com" target="_blank">narrativium+swift@gmail.com</a>><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'Brien <<a href="mailto:narrativium+swift@gmail.com" target="_blank">narrativium+swift@gmail.com</a>> 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't being called by any code in the project, so I would sympathise with this.<br><br>On the other hand I'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's no 'ArithmeticOperation' protocol which Int and Double both conform to, even though they both have a `+ (lhs:Self, rhs:Self) -> 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 'implements' 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>