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]

Re: Suggestion: SCM_DEBUG_REST_ARGUMENTS (fwd)


On 16 May 2000, Keisuke Nishida wrote:

> This is not directly related to your suggestion, but I think it might be
> good if there were some debug flag that enabled the following macros:
> 
> #define SCM_CAR scm_car
> #define SCM_CDR scm_cdr

Actually, that's something I had in mind for some time.  The problem is,
that there is a lot of code using SCM_CAR on non-cons-cells, which was
legal for quite some time.  It was a recent decision to distinguish
between cell accesses and pair accesses.  Thus, currently you would not
get guile running at all if SCM_CAR etc. were defined that way.

However, for the long term I think we could really use macros like the
following:

SCM_DEBUG_CELL_ACCESSES -- Check cell accesses exhaustively, i. e. verify
that the cell pointers actually point to a cell on the heap.  scm_cellp is
a predicate which already performs that kind of test.  We could go even
further here, by also checking that cell elements written as objects are
always read as objects, and that cell elements written as raw data are
always read as raw data.  (see file doc/api.txt)

SCM_DEBUG_PAIR_ACCESSES -- This is what you suggested for pairs:  make
sure that SCM_CAR and friends are only applied to real cons cells.

> This kind of type checking is helpful during development time, and after
> testing, we can just turn off the flag for efficiency.  How about turning
> on all flags by this?
> 
> #define SCM_DEBUG 1
> 
> And I can compile my application by "make CFLAGS='-DSCM_DEBUG=1'" or
> just "make debug" while debugging...

I like that.  For an implementation:  Replace

#ifndef SCM_DEBUG_DEPRECATED
#define SCM_DEBUG_DEPRECATED 0
#endif

by

#ifndef SCM_DEBUG_DEPRECATED
#define SCM_DEBUG_DEPRECATED SCM_DEBUG
#endif

and make sure that SCM_DEBUG is defined as the very first of these
macros.  This simple hack would allow to achieve what you have suggested,
and would still allow to override those macros from the command line.

Cool, isn't it :-)

Dirk


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