next up previous
Next: Control Structures Up: Misellaneous Topics Previous: Misellaneous Topics

Truth Values

We mentioned in an earlier section that nil in Lisp denotes the logical truth value FALSE. To be more precise, the term nil has three separate meanings: it is a symbol with the name 'nil'; it is the logical truth value false; and it is the empty list - the list of zero elements. It can also be used wherever a variable is expected, in which case its value is always nil.

From the Lisp interpreter's point of view, there is absolutely no difference between nil, and (). These two textual symbols appear the same to the Lisp system; in other words, they are two different textual representations of the same Lisp object. In practise, you would find folks using nil to emphasise the truth value FALSE, and () is used to emphasise the empty list.

Just as in C any non-zero value is considered as TRUE in a conditional expression, in Lisp any non-nil value is considered as TRUE. Be that as it may, we also have a symbol t, which is used widely, per convention as the generic TRUE truth value.

The symbols nil and t are unique in one very interesting way - you never need to quote them. This is because they always evaulate to themselves. Take some time out and reflect on that.


next up previous
Next: Control Structures Up: Misellaneous Topics Previous: Misellaneous Topics
Sriram Karra
2005-01-06