> I disagree. We are discussing how to annotate a function in some way so that 
> the compiler knows that the code following it will never be executed *and* so 
> a human who reads the declaration knows that it does not return. “Never" is a 
> poor choice for that. Never what? Never return? Never use this function? 
> Never say never again? 

"Never return". That's why it's in the return type slot, right after the `->`. 
If you read it out loud, you'll read "returns Never", which is exactly correct.

NoReturn, on the other hand, does *not* read well in that slot: "returns 
NoReturn". Huh? I mean, I suppose you won't misunderstand it, but it makes no 
sense whatsoever *as a type name*.

> If you want bottom types for other uses, give them their own appropriate and 
> self documenting names. 

The problem is, types flow through the type system. Use a NoReturn method with 
optional chaining, now you have an Optional<NoReturn>. flatMap over that 
Optional<NoReturn>, now you have a parameter of type NoReturn. What's a 
*parameter* of type NoReturn? You'd want it to be, say, a different bottom type 
named NoPass, but you can't—the type came from a NoReturn, and it's stuck being 
a NoReturn.

Never works pretty well—honestly, surprisingly well—in all of these contexts. 
The method returns Never, so optional chaining gives you an Optional<Never>, so 
flatMap has a Never parameter. I have yet to discover a case where it isn't 
easily interpreted to mean exactly what it really does mean.

-- 
Brent Royal-Gordon
Architechies

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

Reply via email to