Next: , Previous: , Up: Data Types   [Contents][Index]

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 the body of the procedure in the CAR and a pointer to the environment in the CDR. Bits 1 and 2 (zero-based) in the CDR indicate a lower bound on the number of required arguments to the closure, which is used to avoid allocating rest argument lists in the environment cache. This encoding precludes an immediate value for the CDR: In the case of an empty environment all bits above 2 in the CDR are zero.


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.

Macro: ARGC x

Returns the a lower bound on the number of required arguments to closure x, it cannot exceed 3.

Next: , Previous: , Up: Data Types   [Contents][Index]