[swift-evolution] [Proposal] Factory Initializers
cocoadev at charlessoft.com
Wed Dec 23 23:57:26 CST 2015
> On Dec 23, 2015, at 11:09 PM, Riley Testut <rileytestut at gmail.com> wrote:
> Glad to see there's definitely some interest in this community then! I would love to start writing up a final proposal to submit to the Swift-Evolution repo, but I think that last piece of information needed would be the actual method of initialization, specifically should we allow for returning instances from convenience initializers, or should we simply assign to self?
> Personally, I think returning from the initializer makes the most sense, especially because "self" in a protocol extension seems ambiguous. However, I'm not that much in favor that I couldn't be convinced to simply assign to self, because that already has some low level support in the language. Anyone have strong thoughts one way or another?
Assigning to self was always a bit weird. I think returning an instance makes more sense intuitively. It’s also, as you say, unclear exactly what “self” even means in the context of a protocol.
Probably the way I’d do it would be to have the method declared “factory init” and be required to return an object.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution