This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: Upcoming 1.3.2 release
Jim Blandy <jimb@red-bean.com> writes:
> > The new hooks have both Scheme level and C level interfaces.
> >
> > If we add before-gc-hook and after-gc-hook before 1.3.2 we could warn
> > now about %gc-thunk disappearing in 1.3.4.
> >
> > Jim?
>
> This is the first I remember hearing about them.
The change is from 19981123.
RELEASE says
In release 1.3.2:
- remove hook support from boot-9.scm
(only provided for backward compatibility)
I suppose this is OK, since the old hooks was mostly an internal
thing.
> What's the interface?
* Changes to Scheme functions and syntax
** Hooks
A hook contains a list of functions which should be called on
particular occasions in an existing program. Hooks are used for
customization.
A window manager might have a hook before-window-map-hook. The window
manager uses the function run-hooks to call all functions stored in
before-window-map-hook each time a window is mapped. The user can
store functions in the hook using add-hook!.
In Guile, hooks are first class objects.
*** New function: make-hook [N_ARGS]
Return a hook for hook functions which can take N_ARGS arguments.
The default value for N_ARGS is 0.
(See also scm_make_named_hook below.)
*** New function: add-hook! HOOK PROC [APPEND_P]
Put PROC at the beginning of the list of functions stored in HOOK.
If APPEND_P is supplied, and non-false, put PROC at the end instead.
PROC must be able to take the number of arguments specified when the
hook was created.
If PROC already exists in HOOK, then remove it first.
*** New function: remove-hook! HOOK PROC
Remove PROC from the list of functions in HOOK.
*** New function: reset-hook! HOOK
Clear the list of hook functions stored in HOOK.
*** New function: run-hook HOOK ARG1 ...
Run all hook functions stored in HOOK with arguments ARG1 ... .
The number of arguments supplied must correspond to the number given
when the hook was created.
* Changes to the scm_ interface
** Function: scm_make_named_hook (char* name, int n_args)
Creates a hook in the same way as make-hook above but also
binds a variable named NAME to it.
This is the typical way of creating a hook from C code.
Currently, the variable is created in the root module. This will
change when we get the new module system.