2 ms·
I think we need more nulls then. In a sense. Consider a ‘cell’ (value box). 1. Null for no value there. But it can be set, that’s our conventional null. 2. Nu
by wruza 7y ago
I think we need more nulls then. In a sense. Consider a ‘cell’ (value box).
1. Null for no value there. But it can be set, that’s our conventional null.
2. Null for many values from a filter that cannot fit into a single cell. Can be set all at once. Not very null, but cell’s situation-wise it is.
3. Null for no value that cannot be set, e.g. filter produced no values to show or edit at all.
4. Null that is not equal to itself for relational joining in non-sql. (3=4? May be to some extent)
5. Null for a value that must be there, but is not yet (Promising Null). Cannot be set and throws on any comparison, since semantics are unclear until resolving. (4,5) require special isoftype() tests to check their type.
5a. Null for a value that is Promised only on access. Doesn’t throw, but instead yields until it’s done (or throws on failure). You can still check if it is already here, e.g. to choose a better access pattern.
6. Null for a missing key, as opposed to a key holding any of null values above. Absense of a cell itself. Not really 6, but another dimension (remember Perl exists $hash{key}, Js, Python ‘key’ in object, etc, that is hard to test from the object itself).
I’m not a type scientist, but it is clear that semantics of a value in reality decompose in much more ways than just null/non-null. Objects (including primitives) should have at least so much null values when used not in a vacuum, but in loading cross-referenced dataset aggregations that appear in our programs everywhere. I’m not really making any counter-argument here, just my daily job observations to discuss!
But I believe that a language that could cook it all right at the core level and remain convenient to program in will be a million years’ win.
- _hardwaregeek 7y agoWhich is why variants/discriminated unions are so powerful. A common "hump", if you will, that beginners get over with OCaml is an over reliance on booleans. A beginner will write a function that takes an isOpen argument. A more advanced programmer will model the state as a discriminated union that is either Open or Closed. Combine that with generics and you can get generic unions like Maybe which allow you to create sets of states that can be composed with any type.