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

Pyry Jahkola pyry.jahkola at iki.fi
Sun Jun 5 13:49:45 CDT 2016


> On 05 Jun 2016, at 21:26, Антон Жилин via swift-evolution <swift-evolution at swift.org> wrote:
> 
> The following names were suggested: NoReturn, Bottom, None, Never.
> I would pick None, because it looks like opposite to Any and fits nicely in generic types.

I would pick `Never` because `None` would overload the notion of a returnable nothingness with its antonym!

OTOH, "never" is quite unlikely to be a type name in user code, likely pretty googleable, and explains itself quite well in examples like `Result<Value, Never>`.

> I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).
> 
> None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.

I think it would be more useful if the compiler allowed `Never` in every type context (i.e. whatever type `T` was expected, an expression of type `Never` would be allowed), making expressions like the following compile:

    let unwrapped: Int = optional ?? fatalError("explanation why this must not happen")

— Pyry

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


More information about the swift-evolution mailing list