This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: New smob interface
- To: Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se>
- Subject: Re: New smob interface
- From: Greg Badros <badros@cs.washington.edu>
- Date: 21 Jun 1999 17:43:58 -0700
- Cc: Jim Blandy <jimb@red-bean.com>, guile@cygnus.com
- References: <199905231749.TAA09627@mdj.nada.kth.se> <tx1wvxz8m4k.fsf@raeburn.org> <xy7yaifbawy.fsf@mdj.nada.kth.se> <m3ogic53u6.fsf@savonarola.red-bean.com> <xy7iu8ju70n.fsf@mdj-pc.nada.kth.se>
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