4 ms·
> It would be just as clumsy as using null pointers in the first place. When you combine this with type-inference, it's actually really convenient. Check out
by silentbicycle 16y ago
> It would be just as clumsy as using null pointers in the first place.
When you combine this with type-inference, it's actually really convenient. Check out the Maybe monad in Haskell or the option type in OCaml - nullable types are boxed in a variant type of None | Some 'a, you're reminded to check for both possibilities in the few places where it actually matters, and you can quit wasting time and bloating your code writing null tests, forever.
You can define special sentinel subclasses of things in OO languages, but there's usually quite a bit of boilerplate compared to just adding a variant type in ML (and the compiler still can't guarantee that nulls will never occur), so people don't usually bother.