This is the mail archive of the guile@sourceware.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]

Scheme hooks <-> C hooks


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> Guile has two kinds of hooks:
> C hooks and Scheme hooks.  There are two different functions
> scm_c_hook_run and scm_c_run_hook, for example.  This is very
> confusing.  Is there any good reason to do so, or is this going to be
> rewritten?  (If there is a reason related to GC, I think the GC version
> should be named differently...)

Yes, there are now two kinds of hooks:

* C hooks, which run C functions.  Operations on these have prefix
  scm_c_hook_.

* Scheme level hooks, which run Scheme functions ("ordinary" hooks).

I added the former primarily because I've instrumented the GC with
them.  It is not possible to use ordinary hooks for this, and, in
the GC case, running C functions is exactly what you want.

This instrumentation enabled beaking out guardian code and most weak
vector code into their separate modules.  It enables extending Guile
with new similar functionality without modifying libguile.  It also
added a kind of application GC hook which people have been asking for
long.

I then considered that such hooks could be generally useful in
applications, and the fact that we could build the ordinary hooks upon
this layer.  (I haven't had time to do so, though.  If someone wants
to do that, it would probably be good to do so.)

I chose to consistently name these operations using the prefix
scm_c_hook_.  I'm not entirely happy about the name effect you mention
above, the scm_c_hook_run (operation "run" on "C hooks") <->
scm_c_run_hook (C version of "run-hook"), but it is the only one.

I think the C hooks are new enough that we can rename things.  Do you
have a better suggestion for names?

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