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 19 May 2000, Keisuke Nishida wrote:

> Those macros will be used like this, right?
> 
> SCM foo (SCM obj)
> {
>   SCM_DEBUG_PAIR_ACCESSES (obj);
>   return SCM_CAR (obj);
> }

Actually, no:  SCM_DEBUG_PAIR_ACCESSES is either 0 or 1.  If you wanted to
use it that way, you rather would do something like
   if (SCM_DEBUG_PAIR_ACCESSES) SCM_VALIDATE_CONS (obj);
But I think that this is not the way that we should do it.

> In this case, I have to always think of where the object may be wrong
> type.  Instead, I'd like to just write
> 
> SCM foo (SCM obj)
> {
>   return SCM_CAR (obj);
> }
> 
> and if something goes wrong, I want to turn on the Guile's debug option.
> Do you think it is possible?

Here's an outline of what I had in mind:

#define SCM_CAR(x) \
  ((SCM_DEBUG_PAIR_ACCESSES ? (SCM_VALIDATE_CONS (x)) : 0), \
   (SCM_CELL_OBJECT_0 (x)))

So, you don't clutter the code, and switching to debugging mode requires
to do a recompilation with SCM_DEBUG_PAIR_ACCESSES set to 1.  That
solution has some drawbacks, though:  Since x is used twice in the macro,
possible side effects become a problem.  Also, the SCM_VALIDATE_CONS macro
requires that FUNC_NAME be defined.  But, it's just an outline of the
idea.

Best regards
Dirk


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