Previous: Accessing Cell Entries, Up: Unpacking the SCM type


A.2.7.7 Basic Rules for Accessing Cell Entries

For each cell type it is generally up to the implementation of that type which of the corresponding cell entries hold Scheme objects and which hold raw C values. However, there is one basic rule that has to be followed: Scheme pairs consist of exactly two cell entries, which both contain Scheme objects. Further, a cell which contains a Scheme object in it first entry has to be a Scheme pair. In other words, it is not allowed to store a Scheme object in the first cell entry and a non Scheme object in the second cell entry.

— Macro: int SCM_CONSP (SCM x)

Determine, whether the Scheme object x is a Scheme pair, i.e. whether x references a heap cell consisting of exactly two entries, where both entries contain a Scheme object. In this case, both entries will have to be accessed using the SCM_CELL_OBJECT macros. On the contrary, if the SCM_CONSP predicate is not fulfilled, the first entry of the Scheme cell is guaranteed not to be a Scheme value and thus the first cell entry must be accessed using the SCM_CELL_WORD_0 macro.