> Am 05.06.2016 um 20:26 schrieb Антон Жилин via swift-evolution 
> <[email protected]>:
> 
> 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 like to call the type `Void`. `Void` is a type with zero possible 
values. The current `Void` would have to be renamed to `Unit`, the data type 
with exactly one possible value. Less C, More Haskell :) But wait, that's not 
really Haskell-ish, and it's not C-ish either.

From a typing perspective, it's nice to have a noreturn-function be able to 
return any type. For example, the Haskell `error` function has type `String -> 
a`, so you can write

fib :: Integer -> Integer
fib x = error "fib not yet implemented. Sorry"

and it will crash at runtime. Does this make sense for Swift? I don't think so. 
Swift is not a functional programming language, so I think that @noreturn 
shouldn't be force-fitted to look like a type. Given that most developers don't 
really think functionally, but rather imperatively, I don't think it's nice to 
force them to think functionally if they want to understand why @noreturn has 
been turned into `None`.

> 
> I would prefer the type to be simple, and be implemented as a case-less enum 
> (not a bottom value, as in Haskell).

That's a problem. Because `None`, `Never` or `NoReturn` will be a bottom value 
in Swift. "Bottom or not" is not a matter of "implementation", it's a 
conceptual issue. A function returns 'bottom' if and only if it does not return 
at all: that's the definition of 'bottom'.

func foo() -> NoReturn {
    let x = fatalError("crash please")
    print("1+1=2")
    return x
}

The foo-function above will print "crash please" and crash, "1+1=2" will not be 
printed, because `fatalError` is a bottom-value. a @noreturn-function by 
definition returns a bottom value, and bottom shouldn't look like a normal 
type, and IMHO it shouldn't even have a name. So `@noreturn` looks fine to me.

-Michael

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to