This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: New smob interface
Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:
> Greg Badros <badros@cs.washington.edu> writes:
>
> > 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));
>
> > 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));
>
> If you think this saves a lot of typing, then it's OK with me, but I'd
> like the other functions to stay.
Just to clarify, it's not about saving typing. In my experience (with
Scwm), developers, both experienced and newbies alike, cut and paste the
SMOB framework code. In the process, they often forget to modify all
the places that need to be changed, so reducing the number of changes to
be made is a Good Thing.
>
> > Is there a reason why this wasn't preferred before?
>
> I observed that while I had no problems with remembering the types of
> the functions (because they follow fairly naturally from their
> purposes) I constantly had to look up their order. And I think
>
> scm_tc16_arbiter = scm_make_smob_type ("arbiter", 0);
> scm_set_smob_mark (scm_tc16_arbiter, scm_markcdr);
> scm_set_smob_print (scm_tc16_arbiter, prinarb);
>
> is clearer (easier to see the meaning) than
>
> scm_tc16_arbiter =
> scm_make_smob_type_fns ("arbiter", 0,
> scm_markcdr, NULL, prinarb, NULL);
I agree (though the names of the functions that are non-NULL will help.
We could have aliases for NULL for DEFAULT_SMOB_FREE and
DEFAULT_SMOB_EQUALP if that would help readability for you and others.
(Again, this underlines that my issue is not with typing-- I claim such
lines are rarely typed from scratch).
Greg