4 ms·
In general, even if you do have a separate boolean type, you need to distinguish between the function which intended to return null and the function which was u
by moonchild 5y ago
In general, even if you do have a separate boolean type, you need to distinguish between the function which intended to return null and the function which was unable to return anything.
We see here also the distinction between sum types and union types: Maybe Maybe a has three variants: None, Some None, and Some Some a; but (T | null) | null collapses to just T | null.
- b3morales 5y agoThis has a simple solution. In the same way that Maybe is effectively a container, use a container for the Lisp value. I.e., a list. None -> '() Some None -> '(nil) Some Some a -> '(a)
- moonchild 5y agoYes, and this is what e.g. assoc and member do. But in those cases there's already a container, whereas in a hash table you would have to construct a new one. I do think that multiple values are easier to use and result in more direct code; the problem is that they don't enforce correct usage the way a container does.