[swift-evolution] Why you can't make someone else's class Decodable: a long-winded explanation of 'required' initializers

Goffredo Marocchi panajev at gmail.com
Thu Aug 3 01:21:00 CDT 2017


Sent from my iPhone

> On 3 Aug 2017, at 01:09, Jordan Rose via swift-evolution <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 :).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170803/462c4be5/attachment.html>


More information about the swift-evolution mailing list