[swift-evolution] Bridging the gap between protocols and protocol extensions
Brent Royal-Gordon
brent at architechies.com
Sat Jan 9 21:37:45 CST 2016
> Forgive my ignorance if I am wrong, but without the objective-C runtime, we’re looking at dynamism from the perspective of vtables rather than from dynamic dispatch. I would assume the vtable approach would far closer approach vtable lookup than Dynamic dispatch. This appears to have no more overhead than standard protocols, and I would be very hazardous to call that “very slow dispatch”.
That's a large part of what I mean when I ask if it's feasible. Can the protocol witness vtables be made extensible in some way? If they can, and a dynamic protocol extension call is no slower than any other protocol member call, that's great. If they can't, and protocol extension methods need a slower form of dispatch or some kind of translation when crossing module boundaries, that's probably not acceptable.
Class vtables can be extended in this way (and early in Swift's evolution, they even had overridability problems like protocol extensions now do), so I'm guessing it can be done. But protocols are in many ways more complicated than classes—particularly in their need to support multiple conformances rather than single inheritance—so I'm not willing to assume that it can be done without soliciting expert opinions.
--
Brent Royal-Gordon
Architechies
More information about the swift-evolution
mailing list