3 ms·
The only case is when you want to express data is missing (not that a variable is unitialized, but that there's nothing there, think ternary boolean) and that i
by masklinn 16y ago
The only case is when you want to express data is missing (not that a variable is unitialized, but that there's nothing there, think ternary boolean) and that is very neatly taken care of by option types (ML's `option`, Haskell's `Maybe`) which you can easily replicate via union types (create a type Nothing with a single value `nothing` and replace what was formerly a nullable type `T` by the union type `Nothing | T`; depending on whether you want these to be easy to use or not, you may or may not want to add the ability to lift computations into the option type)
- silentbicycle 16y agoRight. The language makes you check for nulls at the few places where the result can go null, and all other tedious null-checking goes away forever. All the advanced type system jiggery-pokery aside -- that's probably the best "normal programmer" example of why ML & Haskell do static typing better. The ALGOL family of languages should have done that years (decades!) ago.