5 ms·
But you are talking about a statically typed way of handling nil. Options and Unions are not nil, which is the point. But you don’t get this in Clojure and nil
by hellofunk 8y ago
But you are talking about a statically typed way of handling nil. Options and Unions are not nil, which is the point. But you don’t get this in Clojure and nil can mean a lot of different things in different contexts, which is more complicated than a simple optional.
- degrews 8y agoSo how _do_ you handle nil without those things? You've said you try to just avoid it, but many functions return nil and there's no easy way around it (e.g. trying to get the max value of an empty list)
- qop 8y agoRepresent the problem programatically. If there's some reason data is missing, use a symbol :idk, :not-provided, etc. Programs DO things, use what you're doing to describe your program, whenever possible. In a better world, max([]) # -> None(T) But sometimes we have to get creative...
- hellofunk 8y agoFunctions only return nil when nil is a valid value in your logic.