<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>This won't work if the protocol is provided by someone else (meaning I can't change its source code) and I want to provide a protocol extension in my own module.</div><div><br></div><div>I like the original idea of having to mark extension methods not in the protocol definition as final. This would make the semantics much clearer.</div><div><br></div><div>-Thorsten</div><div><br>Am 09.12.2015 um 11:22 schrieb T.J. Usiyan 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">I actually suggest something along the lines of <div><br></div><div><span style="font-size:13px"> protocol Foo {</span><br style="font-size:13px"><span style="font-size:13px"> final func doIt() -> String</span><br style="font-size:13px"><span style="font-size:13px"> }</span><br style="font-size:13px"></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px"> extension Foo {</span></div><div><span style="font-size:13px"> final func doIt() -> String {</span><span style="font-size:13px"><br></span></div><div><span style="font-size:13px"> print("I did it.")</span></div><div><span style="font-size:13px"> }</span></div><div><span style="font-size:13px"> final </span>func doThat() {</div><div> print("I did that.")</div><div> }</div><div><span style="font-size:13px"> }</span></div><div><span style="font-size:13px"><br></span></div><div>to indicate that foo will be provided in this module and is not ever to be dynamically dispatched. This draws attention to the fact that dispatch is static in a clear consistent manner.</div><div><br></div><div>TJ</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 9, 2015 at 1:31 PM, Gwendal Roué <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"><span class=""><br>
> Le 9 déc. 2015 à 06:31, Paul Cantrell <<a href="mailto:cantrell@pobox.com">cantrell@pobox.com</a>> a écrit :<br>
><br>
> Gwendal Roué wrote:<br>
>> Whatever the direction this proposal is aiming at, please remember that it is desirable for some APIs to let adopting types "override" the default implementation provided by protocols.<br>
><br>
><br>
> I would certainly hope nobody is proposing changing that! Once a method is virtually dispatched, it should be virtual all the way down to the implementing type.<br>
<br>
</span>Yes, and it’s why I’m concerned. When a protocol provides a default implementation, how will an adopting type invoke that default implementation in its own implementation?<br>
<br>
With classes, it’s easy: you call super.<br>
<br>
With protocols, it’s much less easy, if possible at all, as soon as all methods are dynamically dispatched.<br>
<div class="HOEnZb"><div class="h5"><br>
Gwendal Roué<br>
<br>
<br>
_______________________________________________<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/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Z0lfE0AvBRKWSDAcltP5-2FwA6tH7CtZqjBw6KQdxzh8UeEAuMESPncyStoaIO7wH-2BWDbF-2BuEbIDuOqsnD-2FQTT-2BNms6x3hicDa49RMVZfTBr50BfYfJYAP5BSz3sXrDwKYzmhFfSSR5a7LAQeDZe7rhKkeUApB-2BLsr2QJKT0ZJ4kU3HVr4tSHrQXgbLEOxdqursFcgRpMgNF7tuzKsh-2F4c4yPWNH7a01LjJvprVm27aNf-2F0-2BzjRVpkckwSUmCav2KA" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">
</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>