This is the mail archive of the guile@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: Smob documentation


Jim Blandy <jimb@red-bean.com> writes:

<snip>

>   SCM_NEWCELL (image_smob);
>   SCM_SETCDR (image_smob, image);
>   SCM_SETCAR (image_smob, image_tag);

I think these three lines should be abstracted into a single macro.  We
(in Scwm) write:

SCWM_NEWCELL_SMOB(image_smob, image_tag, image)

and have:

#define SCWM_NEWCELL_SMOB(ANSWER,ID,PSMOB) \
   do { \
     SCM_NEWCELL((ANSWER)); \
     SCM_SETCDR((ANSWER),(SCM) (PSMOB)); \
     SCM_SETCAR((ANSWER),(ID)); \
   } while (0)

It seems to me that it's an implementation detail how SMOBs happen to be 
stored (and there are probably other places where this detail is exposed 
that should be abstracted).  Also, as a practical matter, the lines are
error prone to cut and paste (as everyone does).

I think guile should have:

#define SCM_NEWCELL_SMOB(ANSWER,ID,PSMOB) \
   do { \
     SCM_NEWCELL((ANSWER)); \
     SCM_SETCDR((ANSWER),(SCM) (PSMOB)); \
     SCM_SETCAR((ANSWER),(ID)); \
   } while (0)

Greg

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