|
|
|
|
|
by JoshTriplett
4540 days ago
|
|
> If you have pointers, they sometimes have to start the life uninitialized (i.e. with a value of 0) hence nil pointers. Right, and those pointers must then be declared as potentially null. Or more generally, potentially non-present values of any type need a type like Maybe T. > As you admit yourself, the proposed solutions don't actually get rid of anything. At best they can force you to handle nil value by wrapping it in some wrapper. That's exactly the point: you can tell from a glance at any type whether it can be null or not, and you can only look at the value of something that's guaranteed to not be null; otherwise, you have to handle the null case first. Forcing that to happen at compile time via the type system is far better than dereferencing a null pointer at runtime. |
|