[swift-evolution] overridable members in extensions (was: Why you can't make someone else's class Decodable)

Jordan Rose jordan_rose at apple.com
Mon Aug 7 16:40:08 CDT 2017


> On Aug 2, 2017, at 23:21, Goffredo Marocchi <panajev at gmail.com> wrote:
> 
> 
> Sent from my iPhone
> 
> On 3 Aug 2017, at 01:09, Jordan Rose via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
>> 
>> 'required' initializers are like methods: they may require dynamic dispatch. That means that they get an entry in the class's dynamic dispatch table, commonly known as its vtable. Unlike Objective-C method tables, vtables aren't set up to have entries arbitrarily added at run time.
>> 
>> (Aside: This is one of the reasons why non- at objc methods in Swift extensions can't be overridden; if we ever lift that restriction, it'll be by using a separate table and a form of dispatch similar to objc_msgSend. I sent a proposal to swift-evolution about this last year but there wasn't much interest.)
> 
> If I missed replying to that originally I also missed the chance to say that it would be a lovely idea and dynamic dispatch in some cases is just what the doctor ordered (runtime editable method tables).
> This is especially especially important with extensions for classes and default methods (and the current rules for overriding methods in the implementing class), please resubmit the proposal :).

Thanks for the vote of confidence. :-) Here’s the old proposal for now, likely to be revised soon. https://github.com/jrose-apple/swift-evolution/blob/overridable-members-in-extensions/proposals/nnnn-overridable-members-in-extensions.md <https://github.com/jrose-apple/swift-evolution/blob/overridable-members-in-extensions/proposals/nnnn-overridable-members-in-extensions.md>

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170807/f7427b1e/attachment.html>


More information about the swift-evolution mailing list