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: New smob interface


Some questions on the SMOB updates I'm doing.  I'm planning on adding:

void
scm_set_smob_fns(long tc, 
                 SCM (*mark) (SCM),
                 scm_sizet (*free) (SCM),
                 int (*print) (SCM, SCM, scm_print_state*),
                 SCM (*equalp) (SCM, SCM));

{
  if (mark) scm_set_smob_mark(tc,mark);
  if (free) scm_set_smob_free(tc,free);
  if (print) scm_set_smob_print(tc,print);
  if (equalp) scm_set_smob_equalp(tc,equalp);
}


and

extern void scm_make_smob_type_fns(char *name, scm_sizet size,
                                   SCM (*mark) (SCM),
                                   scm_sizet (*free) (SCM),
                                   int (*print) (SCM, SCM, scm_print_state*),
                                   SCM (*equalp) (SCM, SCM));

to simplify (and remove some redundancies) the code needed to register a 
new type.  e.g.,

void
scm_init_arbiters ()
{
  /* no longer have to repeat scm_tc16_arbiter var name */
  scm_tc16_arbiter = 
    scm_make_smob_type_fns ("arbiter", 0, 
                            scm_markcdr, NULL, prinarb, NULL);

#include "arbiters.x"
}


I think this far better from a S.E. perspective--the only downside I see 
is remembering the order of arguments, but they're all of different
types anyway.  Repeating the var name is very error-prone given how much 
Guile (and Scwm) SMOB code is cut-and-pasted.

Is there a reason why this wasn't preferred before?  I don't necessarily 
think that we need to remove the lower level interfaces, but this
abstraction makes sense to me.

Just wanted to double check before spending time making lots of changes
that you guys don't want to take.

Greg

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