by Ao7bei3s · 7y ago · 0 comments
First, null is generally a value, not a type.
Second, think of bottom types as "does not return".
Taking C as an example: C doesn't have a bottom type, only void which is a unit type (it has a single value, which is anonymous in C). However you can tell the compiler that you _actually_ meant the bottom type:
void panic() __attribute__((noreturn)) {
while(1) {
}
__builtin_unreachable();
}
Scala is also interesting, in that it supports all three (Null, Unit, Nothing).But I didn't go with that because it doesn't answer the question (is null the bottom type? no.), and in the context of return types (the main use case, though not the only) it's equivalent to what I said (no possible return value -> cannot return).