[swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

Joe DeCapo snoogansbc at gmail.com
Sun Dec 3 13:32:24 CST 2017

> On Dec 3, 2017, at 12:54 PM, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:
> The difference is that IUOs are marked by a "!“ whereas dynamic member lookups look just like normal member lookups but unlike them can fail.

We don't even need to bring up IUOs for it to be possible to write code that can fail without visibility at the call site. A contrived example:

func convertToInt(_ val: String) -> Int {
    return Int(val)!

let val = "something"
// ... a bunch of code
let i = convertToInt(val) // Fatal error: Unexpectedly found nil while unwrapping an Optional value

This is trivially easy to do, and has been since Swift 1, but it's not something that has become a widespread issue.

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

More information about the swift-evolution mailing list