www.delorie.com/gnu/docs/guile/guile_128.html   search  
Buy GNU books!

Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] 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 section 18.1.3 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.

Macro: scm_t_bits SCM_UNPACK (SCM x)
Transforms the SCM value x into its representation as an integral type. Only after applying SCM_UNPACK it is possible to access the bits and contents of the SCM value.

Macro: SCM SCM_PACK (scm_t_bits x)
Takes a valid integral representation of a Scheme object and transforms it into its representation as a SCM value.

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003