3 ms·
Swift: Simple, Safe, Inflexible
- Someone 12y ago"Allow required initializers in extensions, and require subclasses to implement these initializers (even if they just call super)" Is that possible? The subclass could live in your application, and the extension method in a plug-in that isn't known to the application (needn't even be on the system or _exist_ when you launch the application) That may work, but I would have to think hard about all kinds of weird scenarios before being sure of it.
- smosher_ 12y agoAt some point you'll end up with breakage unless doing this _causes_ the subclasses to implement the initializer with super (if not already present), not just require it. I don't really like that, but it might actually work. You shouldn't really get to mess with someone else's implementation... that's partly what subclassing is for and that's where it should get fixed. I'm not really familiar with the barrier here since Swift isn't available on my platform, but I can't think of a reason for it to be such a problem, unlike the the other road.
- aaronbrager 12y agoIt's certainly possible. It wouldn't always work easily (for example, in the NSDate example, which uses private subclasses in its class cluster model). But it would be better than what exists now.