[swift-evolution] Remove Failable Initializers

Tino Heth 2th at gmx.de
Wed Mar 9 14:02:57 CST 2016

> So you would you be happy if failable inits were declared like this:
> init() -> self? {}

Not really — afaics, the signature ought to be
static init() -> Self? {
	return self
for maximum consistency ;-) (oh, wait: self is available in the body, so it can't be static… it's even more special than that :-)
The status quo is definitely convenient, and before this thread, I didn't brood over possible flaws it might have; now, I have to admit that initialization in Objective-C not only had the downside of being more cumbersome, but also the advantage of being simpler and more lightweight.

> Unfortunately, Swift decided to make init() a special case thing. It's also the only function type that has special rules around accessing properties, the only one that cannot be named differently, the only one that has special rules around recursing or forwarding to other init() calls
True, but I think those rules can't be removed (maybe it's possible to generalize some; "required" is a candidate for this).

Apparently, getting init right is tougher than it seems at first sight (I'd love to see a brilliant answer for the "make class initialization complexity more progressively disclosed" thread that magically simplifies the whole thing ;-)

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

More information about the swift-evolution mailing list