PREV UP NEXT SCM

6.1.2: Cells

Cells represent all SCM objects other than immediates. A cell has a CAR and a CDR. Low-order bits in CAR identify the type of object. The rest of CAR and CDR hold object data. The number after tc specifies how many bits are in the type code. For instance, tc7 indicates that the type code is 7 bits.

Macro: NEWCELL x
Allocates a new cell and stores a pointer to it in SCM local variable x.

Care needs to be taken that stores into the new cell pointed to by x do not create an inconsistent object. See Signals.

All of the C macros decribed in this section assume that their argument is of type SCM and points to a cell (CELLPTR).

Macro: CAR x
Macro: CDR x
Returns the car and cdr of cell x, respectively.
Macro: TYP3 x
Macro: TYP7 x
Macro: TYP16 x
Returns the 3, 7, and 16 bit type code of a cell.
Cell: tc3_cons
scheme cons-cell returned by (cons arg1 arg2).
Macro: CONSP x
Macro: NCONSP x
Returns non-zero if x is a tc3_cons or isn't, respectively.
Cell: tc3_closure
applicable object returned by (lambda (args) ...). tc3_closures have a pointer to other the body of the procedure in the CAR and a pointer to the environment in the CDR.
Macro: CLOSUREP x
Returns non-zero if x is a tc3_closure.
Macro: CODE x
Macro: ENV x
Returns the code body or environment of closure x, respectively.