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

James Campbell james at supmenow.com
Thu Jan 7 11:56:33 CST 2016


So what would none do for arrays ?

Would it auto initialize an empty array ?

If so would love to play around with alternative key words

On Thu, Jan 7, 2016 at 5:50 PM, Joe Groff via swift-evolution <
swift-evolution at swift.org> wrote:

>
> > 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
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>



-- 
 Wizard
james at supmenow.com
+44 7523 279 698
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160107/d614cc85/attachment.html>


More information about the swift-evolution mailing list