<div dir="ltr"><div><br></div>It sounds to me. <div><br></div><div>In fact it looks like we already have quite interesting information to prepare a rough Draft to summarise all these scenarios in a real proposal.</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 23 August 2016 at 17:50, Xiaodi Wu 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 dir="ltr"><span class="">On Tue, Aug 23, 2016 at 2:13 AM, Charles Srstka <span dir="ltr"><<a href="mailto:cocoadev@charlessoft.com" target="_blank">cocoadev@charlessoft.com</a>></span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><blockquote type="cite">On Aug 23, 2016, at 12:11 AM, Charlie Monroe <<a href="mailto:charlie@charliemonroe.net" target="_blank">charlie@charliemonroe.net</a>> wrote:<br></blockquote><div><blockquote type="cite"><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I don't see it as sub-par in this example (this actually happened to me):</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">@objc protocol Foo {</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="white-space:pre-wrap">        </span>optional func bar()</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">}</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">class FooImpl: Foo {</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="white-space:pre-wrap">        </span>func bar() { ... }</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">}</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Now imagine that bar() gets renamed in the protocol to baz(). You get no warnings, nothing - since the bar() was optional (or can have default implementation as Chalers mentioned). FooImpl still conforms to Foo and bar() can live on there happily.</div></div></blockquote></div><br></span><div>Had that happen to me a bunch of times, especially when I realize that the method needs to have one more argument and then forget to add it everywhere (which is harder to use search-and-replace for, as well).</div><div><br></div><div>Here’s another case where this can bite you:</div><div><br></div><div>In file P.swift:</div><div><br></div><div>protocol P {</div><div><span style="white-space:pre-wrap">        </span>func foo()</div><div>}</div><div><br></div><div>extension P {</div><div><span style="white-space:pre-wrap">        </span>func foo()</div><div>}</div><div><br></div><div>In another file, S.swift:</div><div><br></div><div>struct S: P {}</div><div><br></div><div>Imagine I rename foo in the protocol, but forget to rename it in the extension. The method no longer has a default implementation, and we do indeed get an error, but the error’s in S.swift, in the wrong place. S complains that it doesn’t conform to the protocol. If there were a keyword on foo() in the extension, the compiler warning would be right where the problem is as soon as I renamed the method in the protocol, and it’d be a 2-second fix.</div></div></blockquote><div><br></div></span><div>This is a great motivating example, I think. I'm convinced that we need some way to improve this scenario.</div><div><br></div><div>That said, it'd probably have to be opt-in because major source-breaking changes are going to be frowned upon for Swift 4, and changing the syntax for every single protocol conformance would be hugely source-breaking. That said, I think an opt-in level of safety, where you mark particular declarations or even entire extensions as `@conforming` (or some similar syntax) would give the user most or all of these benefits while maintaining source compatibility. I would be +1 on a proposal like that.</div><div><br></div><div> </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"><span><font color="#888888"><div>Charles</div></font></span></div></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>