<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I like your example because it focusses on the scenarios I often have to deal with: namely to inherit working code that is lacking flexibility and/or abstraction (extensibility). Then I have to find convoluted ways to retrofit some abstractions that do not alter the original code, but let me introduce containment around it so that I can later remove it or extend it <i>despite</i> its author. Java is very flexible in that matter, and it would be great if swift did not get in the way in the name of focussing on forward design (the design of the original author I usually have to dance around). It is IMO part of the magic of typescript: that you can go so far as organize conformance completely unbeknownst to the original loosely (poorly?) defined code.<br><br><div>Regards</div>(From<span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); "> mobile)</span></div><div><br>On Apr 29, 2016, at 4:46 AM, 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 9:40 PM, Erica Sadun <span dir="ltr"><<a href="mailto:erica@ericasadun.com" target="_blank">erica@ericasadun.com</a>></span> wrote:<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"><div style="word-wrap:break-word"><div><div class="h5"><div><blockquote type="cite"><div><div style="font-family:Palatino-Roman;font-size:14px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Without actually trying to understand the details of your math stuff:</div><div style="font-family:Palatino-Roman;font-size:14px;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:Palatino-Roman;font-size:14px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">* If you add a required member in a declaration or extension that declares conformance, it is 'required'. </div><div style="font-family:Palatino-Roman;font-size:14px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">* If it is already defaulted, it is `override required`. </div><div style="font-family:Palatino-Roman;font-size:14px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">* If it is already defaulted but not required, it is `override`</div><div style="font-family:Palatino-Roman;font-size:14px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">* If someone else implements the stuff, you still have to pull it in somehow, but if you do so by conforming to another protocol with an extension, it's not your business, so you don't use any keywords.</div><div style="font-family:Palatino-Roman;font-size:14px;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:Palatino-Roman;font-size:14px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">You use keywords only for stuff that you specifically write, that clarifies the context in which you are writing it. If you do not own a protocol, an extension, or an implementation, you do not change or markup the protocol, extension, or implementation. You're just offering the compiler hints that your otherwise questionable decisions are fully intentional: when overriding an existing implementation and when conforming by supplying a required member.</div><div style="font-family:Palatino-Roman;font-size:14px;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:Palatino-Roman;font-size:14px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">-- E, who still probably missed your point and again apologizes</div></div></blockquote><br></div></div></div><div>* If this is not Swift code it is not affected.</div><div>* If it is Swift code, either use #if swift(>= blah) workarounds or propose that SwiftPM support earlier Swift compilation rules.</div><div>* If this is adopted and the code is in Swift 3, it would already have compliances and you do not need to add anything</div><div><br></div><div>Under what scenario could you possibly use 3rd party Swift 3 code (assuming adoption) that would require annotation/changing?</div><span class=""><font color="#888888"><div></div></font></span></div></blockquote></div><br></div><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></div><div class="gmail_extra"><div style="font-size:12.8px">```</div><div style="font-size:12.8px">// I cannot touch any of the following code</div><div style="font-size:12.8px"><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 style="font-size:12.8px">```</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">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"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><span style="font-size:12.8px">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"><br></div><div style="font-size:12.8px">```</div><div style="font-size:12.8px"><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 style="font-size:12.8px"><br></div><div style="font-size:12.8px">let a = A()</div><div style="font-size:12.8px">a.frobnicate() // "A"</div><div style="font-size:12.8px">let c = C()</div><div style="font-size:12.8px">c.frobnicate() // "Default"</div><div style="font-size:12.8px">```</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">It seems like there is nothing I can do to make this work upon implementation of your proposal.</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>