Next: Non-Descriptor Representations, Up: Numbers [Contents][Index]
Common Lisp’s dynamic typing requires that it be possible to represent any value with a fixed length object, known as a descriptor. This fixed-length requirement is implicit in features such as:
simple-vector
) that can contain any type
of object, and that can be destructively modified to contain
different objects (of possibly different types.)
In order to save space, a descriptor is invariably represented as a single word. Objects that can be directly represented in the descriptor itself are said to be immediate. Descriptors for objects larger than one word are in reality pointers to the memory actually containing the object.
Representing objects using pointers has two major disadvantages:
The introduction of garbage collection makes things even worse, since
the garbage collector must be able to determine whether a descriptor
is an immediate object or a pointer. This requires that a few bits in
each descriptor be dedicated to the garbage collector. The loss of a
few bits doesn’t seem like much, but it has a major efficiency
implication—objects whose natural machine representation is a
full word (integers and single-floats) cannot have an immediate
representation. So the compiler is forced to use an unnatural
immediate representation (such as fixnum
) or a natural pointer
representation (with the attendant consing overhead.)
Next: Non-Descriptor Representations, Up: Numbers [Contents][Index]