[swift-evolution] [Draft] Change @noreturn to unconstructible return type

michael.peternell at gmx.at michael.peternell at gmx.at
Tue Jun 7 16:32:36 CDT 2016

Ok, one last thing, then I go to sleep for today...

Basic Definition of a "Type":
I learned in university that a type is a "set of values".
When a function has a return type of R, it means that it does return a value of type R.

On the other hand, a @noreturn function doesn't return any value, so it doesn't really have a return type. The whole concept of a "bottom type" was made to create a model where every function can be specified as having a return type. This isn't really a useful concept outside of the Haskell language [1].

I like the "Basic Definition of a Type": while it does not generalize to non-returning functions, it includes all functions in the mathematical sense; it includes all functions that are meant to return a value. It includes all functions that terminate and that neither crash nor throw. This "basic definition" is the reason why we have functions at all. We don't have functions in order to build an academic model where we can study denotational semantics [2] in, and that is super-consistent. We have them to calculate things. And we don't calculate values of type `NoReturn` or `Nothing`.

If I haven't convinced you yet => we'll meet again when casting votes for the proposal (if it will ever go into formal review)


[1] Yes, someone will find another language where it is useful too, but anyhow, it's not useful for Swift, Java, Obj-C or C++.
[2] https://en.wikibooks.org/wiki/Haskell/Denotational_semantics

More information about the swift-evolution mailing list