4 ms·
Here's the realization that got me over the "yuck" of nil punning, well two realizations. First, the whole billion dollar mistake is nil POINTERS, not the valu
by blacktriangle 5y ago
Here's the realization that got me over the "yuck" of nil punning, well two realizations.
First, the whole billion dollar mistake is nil POINTERS, not the value nil. Nil in lisp is a value. This is not really a problem, and in fact there's even a design pattern of the null object pattern (https://en.wikipedia.org/wiki/Null_object_pattern https://en.wikipedia.org/wiki/Null_object_pattern) to reproduce this behavior in OOP languages.
Second, in CL, there really is no such thing as nil. Nil is the empty list, they are the same thing. you could search/replace every instance of nil in your code with '() and you'd have the same code. And before you get flashbacks of Javascript and null, just remember unlike JS, there's only a single falsey value and that is the empty list, and there is no automatic type conversion that has surprising boolean semantics.
Ultimately CL manages to turn nil punning into a very nice feature that makes the spaghetti code you're talking about unnessary while also avoiding many of the 'null'-y issues of other languages due to
1) nil is a value
2) there is only one falsey value and that is nil
3) no automatic type conversion