NIL
is a symbol. It's also written as ()
. The output of type-of
is not necessarily useful here. the HyperSpec says about type-of:
Returns a type specifier, typespec, for a type that has the object as
an element.
But given type hierarchies, as well as a universal type (everything is of type t
), the output of type-of can be unhelpful. What's more useful here, if you want to know whether something has a particular type is typep. Using typep, we can see that, regardless of what type-of tells us, that nil
is a boolean, is a symbol, and is a list, and a null. On the other hand, t is a symbol, a boolean, not a list, and not a null.
CL-USER> (type-of nil)
NULL
CL-USER> (type-of t)
BOOLEAN
CL-USER> (typep nil 'boolean) ; both are booleans
T
CL-USER> (typep t 'boolean)
T
CL-USER> (typep nil 'symbol) ; both are symbols
T
CL-USER> (typep t 'symbol)
T
CL-USER> (typep nil 'list) ; only nil is a list
T
CL-USER> (typep t 'list)
NIL
CL-USER> (typep nil 'null) ; only nil is a null
T
CL-USER> (typep t 'null)
NIL
(type-of "elephant")
and(type-of (not "elephant"))
. The fact thatt
happens to be a boolean is accidental. – Leonteen