When you create a hook with
make-hook, you must specify the arity
of the procedures which can be added to the hook. If the arity is not
given explicitly as an argument to
make-hook, it defaults to
zero. All procedures of a given hook must have the same arity, and when
the procedures are invoked using
run-hook, the number of
arguments passed must match the arity specified at hook creation time.
The order in which procedures are added to a hook matters. If the third
add-hook! is omitted or is equal to
procedure is added in front of the procedures which might already be on
that hook, otherwise the procedure is added at the end. The procedures
are always called from the front to the end of the list when they are
The ordering of the list of procedures returned by
matches the order in which those procedures would be called if the hook
was run using
Note that the C functions in the following entries are for handling Scheme-level hooks in C. There are also C-level hooks which have their own interface (see C Hooks).
Create a hook for storing procedure of arity n_args. n_args defaults to zero. The returned value is a hook object to be used with the other hook procedures.
#t if x is a hook,
#t if hook is an empty hook,
Add the procedure proc to the hook hook. The procedure is added to the end if append_p is true, otherwise it is added to the front. The return value of this procedure is not specified.
Remove the procedure proc from the hook hook. The return value of this procedure is not specified.
Remove all procedures from the hook hook. The return value of this procedure is not specified.
Convert the procedure list of hook to a list.
Apply all procedures from the hook hook to the arguments arg .... The order of the procedure application is first to last. The return value of this procedure is not specified.
If, in C code, you are certain that you have a hook object and well
formed argument list for that hook, you can also use
scm_c_run_hook, which is identical to
does no type checking.
The same as
scm_run_hook but without any type checking to confirm
that hook is actually a hook object and that args is a
well-formed list matching the arity of the hook.
For C code,
SCM_HOOKP is a faster alternative to
Return 1 if x is a Scheme-level hook, 0 otherwise.