I just got confused tonight. It is handy for the empty list to be a "false" value. I thought maybe it was only nil that registered as a false value. But since the empty list is a false value, how about the empty string, and the number 0? Lutz, did you already post on your reasons for this design decision?
I can't wait for the answer - this can get philosophical.
The key question is: what is value and when is it nil (as I remember there is no false in lisp, though) ?
If you look over to python, "", empty lists, tuples and numeric 0 are false.
That seems natural, but in lisp you work on lists, an
(0)
is in list - so true.
Even an empty string is a cell, with no value, it is in list - so true.
An empty list says: there is nothing in list, nil - so false.
So for me the question goes down to: is there an element in list or not ?
If you would take e.g. Python's approach you ask: does to value of an element evaluate to true ?
But: how can you then distinguish between
()
and
("")
?
Then both would give nil, but 1. case has no element where 2. has one (an empty string).
So for at least some cases you would need a hasElement* or such.
I think the lisp approach is consistent.
Just my thoughts.
*JAVA TM public final static synchronized unvoid function