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]

Creating hooks from C


OK, I'm still not speaking as maintainer, so this is just a
clarification of my current position in this discussion:

I think we should:

1. Introduce a new C function for creating a hook:

     scm_c_make_hook (n_args)

2. Keep scm_create_hook (name, n_args) as is, except that instead of
   adding the name *in* th hook object, it is added as an object
   property.

   This means creating a binding, creating the hook, GC protecting it
   and adding the name property.

Motivations:

1. I originally thought that 1 was pretty useless, but then again one
never know what needs occur in the future.  Maybe providing this kind
of basic operation could become useful.  For example, some weird
application might want to attach a hook to another object.

In this first kind of use, normal GC behaviour is important, so th
hook should not be protected.

2. I think we should keep in mind what the typical use of a hook
created from C is: An application creates it, and calls it at
occasions determined from the C level.  The purpose is to establish a
connection between the application code and the Scheme level so that
certain pieces of Scheme code can be run at those occasions.

Then scm_create_hook abstracts exactly what we want.  It is symmetric
to gh_new_procedure in all of its respects.  To further motivate the
GC protection, note that the application must be guaranteed that the
hook continues to exist even if all Scheme level references
disappears.

And, would the case arrise where we want hooks to be able to die, we
can use the function under 1.

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