For Gauche 0.9.5

Next: , Previous: , Up: Library modules - Gauche extensions   [Contents][Index]

9.11 gauche.hook - Hooks

Module: gauche.hook

Provides a hook object, which manages a list of closures to be called at certain time.

This API of hooks are upper-compatible of Guile’s, with the following extensions.

Class: <hook>

A hook class, which keeps a list of procedures to be called at once.

The object-apply method is defined on <hook> class, so you can "apply" a hook object as if it were a procedure—which causes all the registered procedure to be invoked.

Function: make-hook :optional (arity 0)

Creates a new hook object with given arity, which should be a non-negative integer.

Function: hook? obj

Returns true if obj is a hook object.

Function: hook-empty? hook

Returns true if hook’s procedure list is empty.

Method: add-hook! (hook <hook>) proc :optional (append? #f)

Adds a procedure proc to hook. If append? is given and true, proc is added at the end of the list. Otherwise, proc is added at the front of the list. The proc has to be called with the arity given at the make-hook.

Method: delete-hook! (hook <hook>) proc
Method: remove-hook! (hook <hook>) proc

Removes proc from the procedure list of hook. Remove-hook! is an alias of delete-hook! just for compatibility with Guile.

Method: reset-hook! (hook <hook>)

Empties hook’s procedure list.

Method: hook->list (hook <hook>)

Returns a copy of hook’s procedure list.

Method: run-hook (hook <hook>) arg …

Calls hook’s procedures in order, with arguments arg …. The number of arguments must match the arity given at make-hook.

Next: , Previous: , Up: Library modules - Gauche extensions   [Contents][Index]