common-lisp Booleans and Generalized Booleans True and False


The special symbol T represents the value true in Common Lisp, while the special symbol NIL represents false:

CL-USER> (= 3 3)
CL-USER> (= 3 4)

They are called “Constant Variables” (sic!) in the standard, since they are variables whose value cannot be modified. As a consequence, you cannot use their names for normal variables, like in the following, incorrect, example:

CL-USER> (defun my-fun(t)
           (+ t 1))
While compiling MY-FUN :
Can't bind or assign to constant T.

Actually, one can consider them simply as constants, or as self-evaluated symbols. T and NIL are specials in other senses, too. For instance, T is also a type (the supertype of any other type), while NIL is also the empty list:

CL-USER> (eql NIL '())
CL-USER> (cons 'a (cons 'b nil))
(A B)