6.11.6 Hooks

A hook is a list of procedures to be called at well defined points in
time. Typically, an application provides a hook h and promises
its users that it will call all of the procedures in h at a
defined point in the application’s processing. By adding its own
procedure to h, an application user can tap into or even influence
the progress of the application.

Guile itself provides several such hooks for debugging and customization
purposes: these are listed in a subsection below.

When an application first creates a hook, it needs to know how many
arguments will be passed to the hook’s procedures when the hook is run.
The chosen number of arguments (which may be none) is declared when the
hook is created, and all the procedures that are added to that hook must
be capable of accepting that number of arguments.

A hook is created using make-hook. A procedure can be added to
or removed from a hook using add-hook! or remove-hook!,
and all of a hook’s procedures can be removed together using
reset-hook!. When an application wants to run a hook, it does so
using run-hook.