[swift-evolution] [Pitch] Nil struct

Anton Zhilin antonyzhilin at gmail.com
Tue Nov 8 15:05:13 CST 2016


2016-11-08 23:43 GMT+03:00 Jose Cheyo Jimenez <cheyo at masters3d.com>:

Thank for thinking of this. I am not sure on the advantage of having nil as
> a concrete type.
>
> Have you seen this talk?
>
> https://realm.io/news/swift-summit-al-skipp-monads/
>
> "The concept of “nil” does not exist in Swift (despite the existence of
> the keyword nil!)"
>
> Does that talk change your mind about this pitch?
>
Not much. We can talk about Swift literals being untyped as much as we
want, but still all of them, except for nil, have an internal storage type,
which is also picked by default.
For example, integer literals are Builtin.Int2048, if I’m not mistaken. But
we just can’t store nil without creating an instance of a potentially
complex type.

And this proposal is not about adding nil to all types. You can do this now
with Any, in any case:

let optionalInt1: Any = 42let optionalInt2: Any = ()   // ewww

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


More information about the swift-evolution mailing list