<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>~Robert Widmann</div><div><br>2016/08/22 14:30、David Cordero via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> のメッセージ:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br><div><b>The problem:</b></div><div>At the moment, looking at the code of a class or a struct implementing a protocol, it is hard to know what methods are actually implementing the protocol and what other methods are just part of the code of the class or struct.<br></div><div><br></div></div></div></blockquote><div><br></div><div>That seems like a feature, not a bug. Why should I as an author care whether a method contributes to a protocol conformance or not if the compiler can tell me that kind of information itself?</div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div>People are trying to fix this problem with pragma marks or moving the code conforming the protocol to a separate extension, but they are just specific good practices or code styles.</div><div><br></div></div></div></blockquote><div><br></div><div>Hm? I haven't seen anything like this used. If you mean doc comments explaining which protocol things are tied to, then that just seems like a style choice.</div><br><blockquote type="cite"><div><div dir="ltr"><div><b>Proposal:</b></div><div>Adding a keyword to the methods conforming protocols. As an example please check the following piece of code which uses the keyword `conform` to explicitly indicate that `myMethod` is a method conforming a protocol.</div></div></div></blockquote><div><br></div><div>Please, no more keywords.</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>```</div><div>protocol MyProtocol {</div><div> func myMethod() -> String</div><div>}</div><div><br></div><div>class MyClass: MyProtocol {</div><div><br></div><div> <b>conform</b> func myMethod() -> String {</div><div> return "Yuhuuu,I am conforming \\o//"</div><div> }</div><div><br></div><div> func whatever() {</div><div> print("I am a boring method and I don't conform anything")</div><div> }</div><div>}</div><div>```</div><div><br></div><div>It would be something similar to the current keyword `override` but for protocols. </div><div><br></div><div>Apart from improving code readability, It would allow the detection, in compilation time, of errors due to code evolution. For example redundant methods that no longer conform anything once the requirement is removed from the protocol for whatever reason.</div></div></div></blockquote><div><br></div><div>If you make a breaking change to a protocol like this, you should have gone through a deprecation cycle to indicate to your clients the appropriate changes you're going to make to the protocol. This aspect of the change seems to if not encourage, highlight, bad behavior.</div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Looking forward your opinions and comments.</div><div><br></div><div>Kind Regards</div><div><br></div><div><br></div></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>