[swift-evolution] Remove Failable Initializers

Chris Lattner clattner at apple.com
Wed Mar 2 17:07:50 CST 2016


On Mar 2, 2016, at 1:11 PM, James Campbell via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Given that we now have error handling and availability checks does it make sense to have Failable Initializers which date back to Swift 1.1?

If I understand correctly, your aim is to simplify the language.  I understand and support that goal generally, but have concerns in this specific case.

Our error handling schema (https://github.com/apple/swift/blob/master/docs/ErrorHandlingRationale.rst#kinds-of-error) defines how error conditions are handled, and one important class of them (e.g. the "string to int" case) is best modeled as returning an optional.  This works really well in practice for functions/methods in general.  

The problem is that removing failable initializers would simplify initializers, but would add complexity that would drive a wedge between initializers and functions, the end result being that a lot of initializers would have to become static functions on types.  I don’t think that everyone would just use error handling.

-Chris



More information about the swift-evolution mailing list