2 ms·
I completely agree. In particular the problem of having NULL as a bottom type is that many languages (like C) don't have a way to express that a certain type is
by simias 9y ago
I completely agree. In particular the problem of having NULL as a bottom type is that many languages (like C) don't have a way to express that a certain type is not nullable in the type system. The nullable aspect is effectively dynamically typed, so you either add NULL checks every time you dereference a pointer or you have to make sure by yourself that a given pointer can never be NULL at a given position in code. For this reason in general when I receive pointers from third party libraries in C I generally always have an `assert(ptr != NULL)` just in case.
In C++ references fill that role but it's not very difficult to get a reference to a NULL or stray pointer by mistake, unless you make sure to forbid raw pointers altogether. NULL effectively ruins your type system by making all your reference types de-facto optional.
TFA points that out but concludes by saying that "Either approach will work", that's a bit curt I think. It's like saying that if the seatbelt doesn't stop you the windshield will, "either approach will work".