[swift-evolution] Proposal: Allow class cluster pattern via dynamic initializer return type

Charles Srstka cocoadev at charlessoft.com
Wed Dec 9 16:55:41 CST 2015

> On Dec 9, 2015, at 4:54 PM, Charles Srstka <cocoadev at charlessoft.com> wrote:
>> On Dec 9, 2015, at 4:11 PM, Jean-Daniel Dupas via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> My experience with class cluster, is that they are confusing and almost implemented wrong. You can as easily create a « class cluster » simply be not exposing the constructor of your class and providing factory methods instead.
> This is not possible with Swift, because it does not have a “private” access modifier. In order for subclasses to be able to override the abstract superclass’s designated initializer, that initializer has to be public. Callers can then call the initializer on the superclass and get undefined behavior.
> Charles

This was meant to say that Swift does not have “protected”, not “private”. Apologies for the typo.


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

More information about the swift-evolution mailing list