[swift-evolution] Proposal: Universal dynamic dispatch for method calls

Kevin Ballard kevin at sb.org
Mon Dec 7 16:22:22 CST 2015


On Mon, Dec 7, 2015, at 02:18 PM, ilya wrote:
>
>>
I wouldn't mind seeing something like the `dynamic` keyword to allow
>>
concrete types to override these protocol extension methods (although
>
> You currently allow it by declaring method to be part of protocol,
> which means that an entry for some method is reserved in the protocol
> witness table. This entry will be filled either by concrete method, if
> present, or by protocol default implementation.

Sure, if you define the protocol yourself, and you want the method to be
available for all instances of the protocol. My `dynamic` suggestion is
meant to cover the cases of a) you didn't define the protocol yourself,
but you want to define a method that can be overridden by any class that
can see your protocol extension, or b) you want to define the method
only for a subset of protocol implementations (e.g. with a `where`
clause) but still want to allow for overriding.

That said, I think `dynamic` is the wrong keyword here, because it means
runtime dynamic dispatch, and what I'm really talking about is just the
ability to have a separate protocol witness table for the extension.

-Kevin Ballard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151207/8447d67e/attachment.html>


More information about the swift-evolution mailing list