Previous: , Up: Notational Conventions   [Contents][Index]


15.1.2.2 Nil — False — Empty List

In Common Lisp the symbol nil is used to represent both

  1. the empty list and
  2. the “false” value for Boolean tests.

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

()’ (empty list)

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.

Examples

(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
“not false” or “true”

Any data object other than nil is construed to be Boolean “not false”, that is, “true”.

symbol t

is conventionally used to mean “true” when no other value is more appropriate.

“false” return

When a function is said to “return false” or to “be false” in some circumstance, this means that it returns nil.

“true” return

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.