Previous: Decimal Numbers, Up: Notational Conventions [Contents][Index]
In Common Lisp the symbol nil
is used to represent both
An empty list may also be written ‘()’; this normally denotes the same object
as nil
.
These two notations may be used interchangeably as far as the Lisp system is concerned.
However, as a matter of style, this book uses the notation
when it is desirable to emphasize the use of an empty list,
nil
when it is desirable to emphasize the use of the Boolean “false”.
'nil
(note the explicit quotation mark) is used to emphasize the use of a symbol.
(defun three () 3) ;Emphasize empty parameter list (append '() '()) => () ;Emphasize use of empty lists (not nil) => t ;Emphasize use as Boolean ``false'' (get 'nil 'color) ;Emphasize use as a symbol
Any data object other than nil
is construed to be Boolean “not false”,
that is, “true”.
t
is conventionally used to mean “true” when no other value is more appropriate.
When a function is said to “return false” or to “be false”
in some circumstance, this means that it returns nil
.
However, when a function is said to “return true” or to
“be true” in some circumstance, this means that it returns some value other
than nil
, but not necessarily t
.