Previous: , Up: Welcome to Lisp   [Contents][Index]


16.4.15 Types

In many languages, variables are what have types, and you can’t use a variable without specifying its type. In Common Lisp, values have types, not variables. Every object has a label attached to it, identifying its type. This approach is called manifest typing. You don’t have to declare the types of variables because any variable can hold objects of any type.

Type declarations are possible, and discussed in Section 13.3.

The built-in Common Lisp types form a hierarchy of subtypes and supertypes. An object always has more than one type. For example, the number 27 is of type:

in order of increasing generality. The type ‘t’ is the supertype of all types, so everything is of type ‘t’.

The function typep takes an object and a type specifier, and returns true if the object is of that type.

> (typep 27 ’integer)
T