[swift-evolution] Proposal: label-only constructors
marc at knaup.koeln
Sun Dec 13 07:23:15 CST 2015
Using a static/class function would make subclassing difficult
- you cannot hide them in subclasses (they're always inherited unlike
- you can't call them from subclass initializers to properly initialize
On Sun, Dec 13, 2015 at 2:21 PM, Drew Crawford via swift-evolution <
swift-evolution at swift.org> wrote:
> On Dec 13, 2015, at 7:13 AM, ilya <ilya.nikokoshev at gmail.com> wrote:
> You can easily call a private parametrized init from a class function
> Sure, but we're just shuffling the deck. We've gone from a bad public API
> to a bad private API.
> Actually, it's worse, because we now have BOTH a bad private API AND a bad
> public API. There is a reason that NSData.dataWithData(...) is a Swift
> compile error.
> The (ab)use of class functions as constructors is a holdover from ObjC
> times. If you want to make an instance in Swift, you should type
> ClassName( and see what autocomplete suggests; you should not have to read
> through the documentation of class functions to see if they are secretly
> constructors that have been filed at the wrong shelf in the library.
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution