Next: , Previous: , Up: Mastering Emacs—Notes and Outline   [Index]


D Lisp Data Types and Structures

primitive built-in data types

a few fundamental object types are built into Emacs. From these primitives every other type is constructed.

  • integer
  • float
  • cons
  • symbol
  • string
  • vector
  • hash-table
  • subr
  • byte-code function
  • record
  • special types—see (elisp)Editing Types
data type

a set of possible objects. Types can overlap, and objects can belong to two or more types. Thus, one cannot ask for the type of an object, but rather whether an object belongs to a type or not. Type declarations do not exist in Emacs Lisp. A Lisp variable can have any type of value, and it remembers whatever value you store in it, type and all. But see (elisp)Restricted Values.

object

piece of data in a Lisp program. Every object belongs to one primitive type. Lisp objects are “self-typing”, that is, the primitive type of each object is implicit in the object itself. Lisp “knows” what kind of object an object is and will not let the programmer treat it as something else.

atom

an atom is any object except a cons cell.

cons cell

a cons cell is an object that consists of two slots, called the CAR slot and the CDR slot. Each slot can “hold” any Lisp object. We also say that the CAR of this cons cell is whatever object its CAR slot currently holds, and likewise for the CDR.

list

a list is a series of cons cells, linked together so that the CDR slot of each cons cell holds either the next cons cell or the empty list. The empty list is actually the symbol ‘nil’. Because most cons cells are used as part of lists, we refer to any structure made out of cons cells as a “list structure”. A Lisp list thus works as a “linked list” built up of cons cells

predicate data-type functions

Each primitive type has a corresponding Lisp function that checks whether an object is a member of that type.


Next: The Sequence Data Type, Previous: Variables, Up: Mastering Emacs—Notes and Outline   [Index]