bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properly handling smobs in macros.c


From: Dirk Herrmann
Subject: Re: Properly handling smobs in macros.c
Date: Fri, 9 Feb 2001 11:08:55 +0100 (MET)

On Thu, 8 Feb 2001, Martin Grabmueller wrote:

> this is not really a bug, but I think the attached change should be
> made for the sake of consistency.
> 
> 2001-02-08  Martin Grabmueller  <address@hidden>
> 
>       * macros.c (scm_macro_name, scm_macro_transformer): Use
>       SCM_SMOB_DATA instead of SCM_CDR.

Thanks a lot.  However, it _is_ a bug, or will be at some time:  For the
long term, we want that SCM_CDR and SCM_CAR will only be used for real
pairs, not for any cell.  Currently, there are lots of places where
SCM_CAR and SCM_CDR are used to access cell entries of non-pair objects.
This has historical reasons, since the alternative macros like
SCM_SMOB_DATA, SCM_CELL_OBJECT*, SCM_CELL_WORD* were introduced only a
year ago or so.  Some interesting information about these macros can be
found in the file guile-core/doc/api.txt.

If you feel like hunting such uses of SCM_C[AD]R, here is a small code
piece that could help you.  Change the definitions in pair.h according to
the code below, and define SCM_DEBUG_PAIR_ACCESSES as 1 when calling make:

  make clean
  make "CFLAGS=-g -DSCM_DEBUG_PAIR_ACCESSES=1"

Best regards and thanks for your help to improve guile.
Dirk Herrmann


#if (SCM_DEBUG_PAIR_ACCESSES == 1)
# define SCM_VALIDATE_PAIR(cell, expr) (!SCM_CONSP (cell) ? abort (), 0 : 
(expr))
#else
# define SCM_VALIDATE_PAIR(cell, expr) (expr)
#endif

#define SCM_NULLP(x)            (SCM_EQ_P ((x), SCM_EOL))
#define SCM_NNULLP(x)           (!SCM_NULLP (x))

#define SCM_CAR(x)              (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_0 (x)))
#define SCM_CDR(x)              (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_1 (x)))

#define SCM_SETCAR(x, v)        (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_0 
((x), (v))))
#define SCM_SETCDR(x, v)        (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_1 
((x), (v))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]