[swift-evolution] Swift null safety questions

Robert Bennett rltbennett at icloud.com
Mon Mar 6 21:25:40 CST 2017


The explicit-at-definition, implicit-at-call-site force unwrapping of optionals can be achieved with this syntax:

func test(name1: String!, name2: String!) {
	print(name, name2)
}

// prints 'first second' - does not print 'Optional("second")'
test(name1: "first", name2: Optional("second"))

I think this is about as ergonomic as possible.

I agree with Austin that a force-unwrap error should be fatal. There is sufficient syntax in the language to allow the safe handling of optionals that we don't need to make the unsafe handling of optionals safe as well. You have the opportunity to "catch" a nil value with an if-let or a guard-else; I don't see a compelling reason to allow the catching of errors arising from circumventing those constructs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170306/5fe0af5c/attachment.html>


More information about the swift-evolution mailing list