wiki:DescribeHook
close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

What is a hook?

A hook in CLFSWM is a function, a symbol, a list of functions or a list of symbols.

A function is called as is with parameters passed from call-hook.

A symbol function is called like a function.

If the hook is a list then functions or symbols are called in order.

Call-hook return the result of the last function executed in the hook.

For example:

(defun fun-1 (x y) (print (list 'fun-1 x y)))
(defun fun-2 (x y) (print (list 'fun-2 x y)))
(defun fun-3 (x y) (print (list 'fun-3 x y)))

(defvar *hook* #'fun-1)
(call-hook *hook* 10 20)
=> (FUN-1 10 20)

(setf *hook* 'fun-2)
(call-hook *hook* 10 30)
=> (FUN-2 10 30)

(setf *hook* (list 'fun-1 'fun-2 'fun-3))
(call-hook *hook* 10 "foo")
=> (FUN-1 10 "foo")
   (FUN-2 10 "foo")
   (FUN-3 10 "foo")

(setf *hook* (list #'fun-1 #'fun-2 #'fun-3))
(call-hook *hook* 10 "foo")
=> (FUN-1 10 "foo")
   (FUN-2 10 "foo")
   (FUN-3 10 "foo")
Last modified 16 years ago Last modified on 03/18/08 14:16:38