<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I'm glad you brought this up and provided a clear example <span style="background-color: rgba(255, 255, 255, 0);">Xiaodi.</span></div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Erica, as I mentioned a few days ago (and Dave A gave +1) this proposal cannot break retroactive modeling if it is going to fly. Can you please update it to clarify how you envision it interacts with retroactive modeling? Would these new keywords only be required when the conformance is declared in the same module as the method? </div><div id="AppleMailSignature"><br>Sent from my iPad</div><div><br>On Apr 28, 2016, at 12:48 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 28, 2016 at 12:25 PM, Erica Sadun <span dir="ltr"><<a href="mailto:erica@ericasadun.com" target="_blank">erica@ericasadun.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="">><br>
> On Apr 28, 2016, at 11:05 AM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>> wrote:<br>
><br>
> How is retroactive modeling accommodated in this scheme? Say I want to conform three types I don't own to a protocol of my design and supply a default implementation for a protocol requirement. How would I go about it?<br>
<br>
</span>extension NotMyType: ProtocolIdesigned {...}<br>
<br>
extension NotMyProtocol {<br>
required func method1() {...}<br>
override required func method2() {...} // assumes NMP has already provided default<br>
func newThing() {...}<br>
}<br>
<br>
The only tricky bit is when NotMyProtocol already has a default required func implementation and an override required func implementation (although that should be rare). In such case, you probably have to create a new protocol DerivedProtocol: NotMyProtocol and work from there. The override in the DerivedProtocol will then take priority over the override in NotMyProtocol.<br></blockquote><div><br></div><div>Sorry, that's not my question, which doesn't involve protocols I don't own. Let me restate. Given three types I don't own as follows:<br></div><div><br></div><div>```</div><div><div>struct A {</div><div> func frobnicate() { print("A") }</div><div>}</div><div>struct B {</div><div> func frobnicate() { print("B") }</div><div>}</div><div>struct C { }</div></div><div>```</div><div><br></div><div>I want to conform them to a protocol of my own design, Frobnicatable, and supply a default `frobnicate()`:</div><div><br></div><div>```</div><div><div>protocol Frobnicatable {</div><div> func frobnicate()</div><div>}</div><div>extension Frobnicatable {</div><div> func frobnicate() { print("Default") }</div><div>}</div><div>extension A: Frobnicatable { }</div><div>extension B: Frobnicatable { }</div><div>extension C: Frobnicatable { }</div></div><div><br></div><div>let c = C()</div><div>c.frobnicate() // "Default"</div><div>```</div><div><br></div><div><div>(Yes, I realize there are issues regarding static and dynamic dispatch that limit the utility of this particular example--let's leave those aside for now.)</div><div>Where would I affix keywords such as `required` and `override` to make this work after implementation of your proposal?</div></div><div><br></div></div></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>