3 ms·
> And there is no other empty list but nil. Okay? That still doesn't justify using it as replacement for #f (which is also a unique value). Or as #t for that m
by Joker_vD 2y ago
> And there is no other empty list but nil.
Okay? That still doesn't justify using it as replacement for #f (which is also a unique value). Or as #t for that matter, there is also only one #t in the entire system.
> An empty array or string are not false. Zero is not false.
And an empty list is also not false, only #f is false. So simple and uniform! Wait, there is no #f, but an empty list is false? Why? Why is empty list so special? Or, alternatively, why are you using the false value as an empty list? The idea to represent a list as
[1 | [2 | [3 | False]]]
is quite strange. Just spare an atom, it's only what, eight bytes nowadays?
> how to test for false
In sane programming languages, the booleans are self-testing, so to speak, and they are the only values with such property, so:
if not val then ...
(if (not val) ...
tests for false.
> or for empty
if val_specific_is_empty(val) then ...
(if (null? val) ...
But of course, it only matters for languages that have other options for building composite data types than CONS-ing two items together.
- kazinator 2y agoNo language with completely separate booleans has ever had a fun club. (Scheme isn't that language, because everything that is not #f is true.) List processing is cumbersome in Scheme because the empty list is't false, and because car and cdr cannot be applied to (). (Which, stupidly, isn't even self-evaluating; you have to use '()). The empty list is special because once upon a time lisp emphasized list processing more. Complex list processing is still important in metaprogramming, and representations of flexible dynamic data sets. You're not working with lists, it utterly doesn't matter that nil also has a role as the empty list. Just like you don't care that your physician also plays saxophone in a jazz band; he's not doing it during your appointment.