[swift-evolution] Proposal: disallow nil in favor of .None

Radosław Pietruszewski radexpl at gmail.com
Sun Apr 10 16:13:40 CDT 2016

Pretty sure it has been discussed already.

MHO: much of the power of Optionals in Swift is that they’re more than just a .None/.Some(T) enum. They’re tightly integrated into the language. You never say .Some(value) — values are just lifted to optionals automatically. And if we never directly say .Some(T), why should we say .None? Let’s treat optionals as part of the language, and the enum an implementation detail. Let’s use automatic lifting to optionals, all the `if let`s and other helpful syntax, and say `nil` instead of .None — after all, it’s an important enough part of the language to deserve its own keyword. (A keyword, that, as an additional benefit, will be more immediately understood by someone new to Swift)

— Radek

> On 10 Apr 2016, at 22:53, Paul Young via swift-evolution <swift-evolution at swift.org> wrote:
> Please forgive me if this has already been discussed, but I couldn't find reference to it anywhere.
> My proposal is pretty simple – disallow the use of `nil` and require the use of `.None` instead.
> I would like to understand if there are any technical (or otherwise) reasons for `nil` to remain, or if it simply a remnant of interop with Objective-C.
> Thanks,
> Paul
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list