[swift-evolution] [Pitch] Never as a bottom type
André Videla
andre.videla at gmail.com
Mon May 15 00:44:53 CDT 2017
> Joe also referred to the following model in a thread about Typed Throws.
>
> () -> () == () throws Never -> ()
> () throws -> () == () throws Error -> ()
That makes sense! As a bottom type it would be perfectly fit for this.
> On 15 May 2017, at 03:01, Robert Widmann <devteam.codafi at gmail.com> wrote:
>
> Though our type lattice doesn’t necessarily have a bottom in the way you’re looking for, you can use Never-returning functions to inhabit a combinator that will do this for you.
Very useful.
What do you think of [] as [Never], or nil as Optional<Never>. Can the current inference and subtyping rules deal with that?
If it can there are very interesting things to be done in order to help the developper fill up those placeholders. Typically, the compiler could compute the expected type of a placeholder and IDEs could show this to the user. For example alt-click on undefined could display
`func undefined() -> Never. Expected: Int`
(Of course this get horribly complex when the compiler needs to compute the lowest upper bound of an intersection of types)
> On 15 May 2017, at 02:04, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>
> Clearly many uses for this; would like to see it some day, definitely. However, IIRC, the last day for any _code_ to be incorporated in Swift 4 is June 1. There's simply no chance that this can be considered for the current phase of Swift evolution.
Not a problem, I do no think it is necessary to rush out this feature. But I really wanted to see if it is something that other people here consider useful. I am glad to see that it’s the case. What would be a good timing for a proposal on this matter?
More information about the swift-evolution
mailing list