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

Félix Cloutier felixcca at yahoo.ca
Thu Jan 7 13:09:35 CST 2016


That would leave you with runtime checks instead of compile-time checks and I totally disagree with that.

Félix

> Le 7 janv. 2016 à 13:45:21, Amir Michail <a.michail at me.com> a écrit :
> 
> 
>> On Jan 7, 2016, at 1:40 PM, Félix Cloutier <felixcca at yahoo.ca <mailto:felixcca at yahoo.ca>> wrote:
>> 
>> An implicitly-unwrapped optional would do almost that, no?
>> 
> 
> You can use “none” to eliminate implicitly unwrapped optionals from the language.
> 
>> Félix
>> 
>>> Le 7 janv. 2016 à 12:46:53, Amir Michail via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> a écrit :
>>> 
>>> 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
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>> 
> 

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


More information about the swift-evolution mailing list