This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

tags.h


Hello!

Now that we have some experience with different alternatives for defining
SCM, I am planning to change the definition in tags.h in the way shown
below.  Also, the predicate SCM_EQ_P is provided, since when SCM is
defined as a union, comparing two SCM variables with the operator == is
not allowed in C.

The comment for the SCM_VOIDP_TEST mode is claiming that it is the
default, because once it will be.  I don't know if the comment should be
changed to indicate that it _once_ will be the default?

Comments, objections?

Best regards
Dirk Herrmann



/* #define SCM_STRICT_TYPING */
/* #define SCM_VOIDP_TEST    */

/* In the beginning was the Word:
 */
typedef long scm_bits_t;

/* But as external interface, we use SCM, which may, according to the desired
 * level of type checking, be defined in several ways:
 */
#if defined (SCM_STRICT_TYPING)
/* Use this for _compile time_ type checking only, since the compiled result
 * will be quite inefficient.  The right way to make use of this mode is to do
 * a 'make clean' of your project, 'make all CFLAGS=-DSCM_STRICT_TYPING', fix
 * your errors, and then do 'make clean; make all'.
*/
    typedef union { struct { scm_bits_t n; } n; } SCM;
    static SCM scm_pack(scm_bits_t b) { SCM s; s.n.n = b; return s; }
    #define SCM_UNPACK(x) ((x).n.n)
    #define SCM_PACK(x) (scm_pack (x))
#elif defined (SCM_VOIDP_TEST)
/* This is the default, which provides an intermediate level of compile time
 * type checking while still resulting in very efficient code.
 */
    typedef void * SCM;
    #define SCM_UNPACK(x) ((scm_bits_t) (x))
    #define SCM_PACK(x) ((SCM) (x))
#else
/* This should be used as a fall back solution for machines on which casting
 * to a pointer may lead to loss of bit information, e. g. in the three least
 * significant bits.
 */
    typedef scm_bits_t SCM;
    #define SCM_UNPACK(x) (x)
    #define SCM_PACK(x) (x)
#endif


/* SCM values can not be compared by using the operator ==.  Use the following
 * macro instead, which is the equivalent of the scheme predicate 'eq?'.
 */
#define SCM_EQ_P(x, y) (SCM_UNPACK (x) == SCM_UNPACK (y))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]