Image

Lisp and memory

The (3) Lisp tutorials I'm working from all stress that a cons cell has only two parts, the car and the cdr, both of which are pointers. One of them (Paul Graham's book) conceeds that some Common Lisp implementations actually store small atoms directly, rather than using a pointer.

I have no problem with the idea of the cdr just being a pointer, as it always points to the next cons cell making up the list. It seems to me, though, that each cons cell would either need a flag saying that it's a cons cell rather than an atom, or something to record whether its own car it pointing to a list (cons cell) or an atom.

I understand that the implementation is likely to vary, but am I right that there's more to it than just two pointers?