Changes between Initial Version and Version 1 of DescribeHook

Show
Ignore:
Timestamp:
03/18/08 07:16:38 (6 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DescribeHook

    v1 v1  
     1= What is a hook? = 
     2 
     3A hook in [wiki:CLFSWM] is a function, a symbol, a list of functions or a list of symbols. 
     4 
     5A function is called as is with parameters passed from call-hook. 
     6 
     7A symbol function is called like a function. 
     8 
     9If the hook is a list then functions or symbols are called in order. 
     10 
     11Call-hook return the result of the last function executed in the hook. 
     12 
     13For example: 
     14 
     15{{{ 
     16(defun fun-1 (x y) (print (list 'fun-1 x y))) 
     17(defun fun-2 (x y) (print (list 'fun-2 x y))) 
     18(defun fun-3 (x y) (print (list 'fun-3 x y))) 
     19 
     20(defvar *hook* #'fun-1) 
     21(call-hook *hook* 10 20) 
     22=> (FUN-1 10 20) 
     23 
     24(setf *hook* 'fun-2) 
     25(call-hook *hook* 10 30) 
     26=> (FUN-2 10 30) 
     27 
     28(setf *hook* (list 'fun-1 'fun-2 'fun-3)) 
     29(call-hook *hook* 10 "foo") 
     30=> (FUN-1 10 "foo") 
     31   (FUN-2 10 "foo") 
     32   (FUN-3 10 "foo") 
     33 
     34(setf *hook* (list #'fun-1 #'fun-2 #'fun-3)) 
     35(call-hook *hook* 10 "foo") 
     36=> (FUN-1 10 "foo") 
     37   (FUN-2 10 "foo") 
     38   (FUN-3 10 "foo") 
     39}}}