[swift-evolution] Proposal: Add "none" and simplify the language.

Joe Groff jgroff at apple.com
Thu Jan 7 11:50:14 CST 2016


> On Jan 7, 2016, at 9:46 AM, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Examples:
> 
> var x:Int = none // uninitialized but not an optional
> 
> print(x) // run-time error as x is uninitialized
> 
> if x == nil { … } // compile time error… x can never be nil because it is not an optional
> 
> if x == none { x = 2 } // … but it can be uninitialized
> 
> Optionals can also be uninitialized:
> 
> var y:Int? = none // uninitialized and an optional
> 
> if y == nil { … } // run-time error as y is uninitialized
> 
> y = nil
> 
> if y == nil { … } // fine

This use case should be supportable as a property behavior; check out the "delayed" example from my proposal:

https://gist.github.com/jckarter/f3d392cf183c6b2b2ac3

-Joe


More information about the swift-evolution mailing list