<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 28, 2016, at 8:46 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><div class=""><div dir="ltr" class=""><div class="gmail_extra">Let's return to the toy example. Suppose I license the following code from a third party. I am allowed to incorporate it unmodified into my project:</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><div style="font-size:12.8px" class="">```</div><div style="font-size:12.8px" class="">// I cannot touch any of the following code</div><div style="font-size:12.8px" class=""><div class="">struct A {</div><div class="">&nbsp; &nbsp; func frobnicate() { print("A") }</div><div class="">}</div><div class="">struct B {</div><div class="">&nbsp; &nbsp; func frobnicate() { print("B") }</div><div class="">}</div><div class="">struct C { }</div></div><div style="font-size:12.8px" class="">```</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">The code above has three types that conform to no protocols. Nothing would change on adoption of your proposal. As licensed to me from the third party, there are no protocols for it to conform to.</div><div style="font-size:12.8px" class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div style="font-size:12.8px" class=""><span style="font-size:12.8px" class="">Now, in a separate file, as part of my own code, I want to conform these three types to a protocol of my own design, Frobnicatable, and supply a default `frobnicate()`:</span></div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">```</div><div style="font-size:12.8px" class=""><div class="">protocol Frobnicatable {</div><div class="">&nbsp; &nbsp; func frobnicate()</div><div class="">}</div><div class="">extension Frobnicatable {</div><div class="">&nbsp; &nbsp; func frobnicate() { print("Default") }</div><div class="">}</div><div class="">extension A: Frobnicatable { }</div><div class="">extension B: Frobnicatable { }</div><div class="">extension C: Frobnicatable { }</div></div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">let a = A()</div><div style="font-size:12.8px" class="">a.frobnicate() // "A"</div><div style="font-size:12.8px" class="">let c = C()</div><div style="font-size:12.8px" class="">c.frobnicate() // "Default"</div><div style="font-size:12.8px" class="">```</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">It seems like there is nothing I can do to make this work upon implementation of your proposal.</div></div></div>
</div></blockquote></div><br class=""><div class="">Is this your desired behavior or is this the behavior you expect?</div><div class="">By implementing a default, you inherit that behavior in all three, because *you* added it.</div><div class=""><div class="">I expect the compiler to complain at your default because you did not mark it as required.</div></div><div class=""><br class=""></div><div class="">If you want to use the inherent frobnicate and not the default one that you just added,</div><div class="">you will need to do something like:</div><div class=""><br class=""></div><div class="">extension A: Frobnicate {</div><div class="">&nbsp; &nbsp;override required frobnicate = A.frobnicate</div><div class="">}</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div></body></html>