3 ms·
No because the type bottom has no valid values, whereas null as one valid value, namely null. A function that returns bottom must loop forever, because there ar
by aliceryhl 6y ago
No because the type bottom has no valid values, whereas null as one valid value, namely null. A function that returns bottom must loop forever, because there are no values that it would be valid for the function to return.
- Sharlin 6y agoLoop forever, or, more commonly in actual use cases, terminate via a nonlocal return (eg. exceptions, `longjmp`, `abort`). As an aside, in any programming language that does not support/enforce total functions, the return type `T` of any function is actually the sum type `T | Bottom`, which is to say, "this function either returns a value of type `T` or never returns to its caller at all!" Also used as the type of expressions that do not return a value (things like `break`, `continue`, or `throw` in expression-oriented languages).
- aliceryhl 6y agoI mean, `T | Bottom` is the same type as `T`, so what you're saying is vacuously true.