Next: , Previous: , Up: The language   [Contents][Index]


5.3 Data Types

The way that data is represented in Lisp is fundamentally different to languages such as C or Fortran. In Lisp each piece of data (or value) has two basic attributes: the data and the type of the data. This means that type checking is performed at run-time on the actual data itself, not at compile-time on the “variable” holding the data.

Also, there are no “pointers” in Lisp. As in the Java programming language, all values are references to data structures, with each actual data structure (or Lisp Object) being able to have as many values referring to it concurrently as necessary. Because of this lack of pointers, there can be no memory-leakage in Lisp—when an object has no more extant references, it is automatically deallocated (see Garbage Collection).

Most Lisp objects are a member of one of the primitive types; these are types built into the Lisp system and can represent things like strings, numbers, cons cells, vectors, etc… Other primitive types may be defined at run-time.

More complex objects may be constructed from these primitive types, for example a vector of three elements could be regarded as a type triple if necessary. In general, each separate type provides a predicate function which returns true when applied to an object of its own type.

Finally, one of the most important differences between Lisp and other languages is that there is no distinction between programs and data. But this will be explained later.


Next: , Previous: , Up: The language   [Contents][Index]