9.2.5.1 Relationship Between SCM and scm_t_bits

A variable of type SCM is guaranteed to hold a valid Scheme object. A variable of type scm_t_bits, on the other hand, may hold a representation of a SCM value as a C integral type, but may also hold any C value, even if it does not correspond to a valid Scheme object.

For a variable x of type SCM, the Scheme object’s type information is stored in a form that is not directly usable. To be able to work on the type encoding of the scheme value, the SCM variable has to be transformed into the corresponding representation as a scm_t_bits variable y by using the SCM_UNPACK macro. Once this has been done, the type of the scheme object x can be derived from the content of the bits of the scm_t_bits value y, in the way illustrated by the example earlier in this chapter (see Cheaper Pairs). Conversely, a valid bit encoding of a Scheme value as a scm_t_bits variable can be transformed into the corresponding SCM value using the SCM_PACK macro.