GNU Info

Info Node: (librep.info)nil and t

(librep.info)nil and t


Next: The Lisp Reader Up: Intro
Enter node , (file) or (file)node

nil and t
---------

   In the rep Lisp dialect there is a single data value representing
boolean "false"--the empty list, written as `()'. All other values are
considered "not-false", i.e. "true".

   By convention the constants `nil' and `t' are used to represent the
canonical boolean values. The constant variable `nil' evaluates to the
empty list (i.e. "false"), while `t' evaluates to itself (i.e.
not-"false", therefore "true").

   Reiterating, all of the conditional operations regard _anything_
which is not `()' as being true (i.e. non-false). The actual symbol `t'
should be used where a true boolean value is explicitly stated, to
increase the clarity of the code.

   So, `()', and its alias `nil', represent both the empty list and
boolean falsehood. Most Lisp programmers write `()' where its value as
a list should be emphasized, and `nil' where its value as boolean false
is intended. Although neither of these values need be quoted (Note:
Quoting), most programmers will quote the empty list to emphasize
that it is a constant value. However `nil' should not be quoted, doing
so would produce the _symbol_ `nil', not boolean falsehood. For example:

     (append '() '()) => ()          ;Emphasize use of empty lists
     
     (not nil) => t                  ;Emphasize use as boolean false
     
     (get 'nil 'color)               ;Use the symbol `nil'

   When a function is said to "return false", it means that it returns
the false boolean value, i.e. the empty list. When a function is said
to "return true", this means that any non-false value is returned.


automatically generated by info2www version 1.2.2.9