Next: , Previous: Immediate Datatypes, Up: How Guile does it

A.2.5 Non-immediate Datatypes

A non-immediate datatype is one which lives in the heap, either because it cannot fit entirely within a SCM word, or because it denotes a specific storage location (in the nomenclature of the Revised^5 Report on Scheme).

The SCM_IMP and SCM_NIMP macros will distinguish these from immediates; see Immediates vs Non-immediates.

Given a cell, Guile distinguishes between pairs and other non-immediate types by storing special tag values in a non-pair cell's car, that cannot appear in normal pairs. A cell with a non-tag value in its car is an ordinary pair. The type of a cell with a tag in its car depends on the tag; the non-immediate type predicates test this value. If a tag value appears elsewhere (in a vector, for example), the heap may become corrupted.

Note how the type information for a non-immediate object is split between the SCM word and the cell that the SCM word points to. The SCM word itself only indicates that the object is non-immediate — in other words stored in a heap cell. The tag stored in the first word of the heap cell indicates more precisely the type of that object.

The type predicates for non-immediate values work correctly on any SCM value; you do not need to call SCM_NIMP first, to establish that a value is non-immediate.