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: SMOBs (was: Re: mildly incompatible change)


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

> I think you have smobs basically right.  The are document, in a sense,
> at http://www.red-bean.com/guile/docs/data/data_toc.html.

Thanks for the tip!  I guess I could have found it if I'd tried-- it
turned up #2 in Alta Vista search [Guile Smobs].  Also found it with
grep in guile-doc-19980419/sources/, though apparently it wasn't
installed in /usr/local/info by default.

> The CALL method is pretty interesting; Roland McGrath and I did a
> little Scheme interpreter in 1991 that had something very similar.
> However, I tend to think it's better to just add a completely separate
> tag for foreign functions; I'm not sure it's so good to make ordinary
> data objects callable that we should make it so easy.

Well, only those types ("tags" I guess you'd say) with a non-NULL
(*call) member would be callable.  Are you suggesting that foreign
functions should be something other than smobs altogether?

> > At first, I used a single `destroy' the way I assume the smob `free'
> > function works.  Later, I realized that the destructor might want to
> > call Lisp code, which shouldn't happen while any mark bits are set.
> > So I split object destruction into `sweep', which is called during
> > gc_sweep(), and `destroy', called when it is safe to invoke user
> > code.
> 
> I hadn't thought about that.  The whole destructor question is really
> pretty hairy; witness the discussions that flare up on the GC list
> periodically.

I didn't know there was a GC list, but I've already had second
thoughts about this since yesterday, so I can just imagine the
flamage.  R5RS says something like "Scheme objects have infinite
extent", which makes it seem illogical for Scheme to be involved when
one of its own is gc'ed.  But maybe there are practical reasons that
this should be possible.  No opinion.

-John