3 ms·
Common Lisp addresses some of these problems out of the box. It returns a second value from some functions to distinguish between "nothing was found" vs. "A val
by dreamcompiler 7y ago
Common Lisp addresses some of these problems out of the box. It returns a second value from some functions to distinguish between "nothing was found" vs. "A value was found, and it is nil."
CL also uses a special reserved value to mean "unbound" so it's always clear when a symbol or instance is uninitialized vs. initialized with nil. It's not possible for the programmer to portably see this value or assign it but there are functions to find out if a container is unbound and set it to such.
Having said that, problems remain. I prefer to use maybe and error monads in my CL programs now rather than just returning nil. That solves most of the remaining issues.