This example illustrates "typical" use of action lists. The
forms might be scattered across several files (
, and so on). Each of the functions, such as
, and so on, take one argument:
(define-action-list "On arrival at office"
:documentation "Things to do in the morning"
:dummy-actions '("Look busy")
:default-order '(:before "Look busy"))
(define-action "On arrival at office" "Read mail" 'read-mail)
(define-action "On arrival at office" "Greet co-workers"
(define-action "On arrival at office" "Drink much coffee"
'wake-up:after "Locate coffee machine")
(define-action "On arrival at office" "Locate coffee machine"
(defun my-morning (hassled-p Monday-p)
(execute-actions ("On arrival at office"
<rest of my-morning code goes here >)
This example illustrates use of execution-functions and post-processing
Here are the implementation details, which are hidden from the "user".
(defstruct (thing (:constructor make-thing (name number)))
(make-unregistered-action-list :sort-time :define-action
(defun do-things (function &optional post-process)
(execute-actions (*things* :post-process post-process)
(defun act-on-things (things other-args-list &key post-process)
(things ignore thing post-process)
(funcall function thing))))
The interface is given below. The internals of the mapping mechanism are hidden.
(defmacro define-thing (name number)
`(let ((,thing (make-thing ,name ,number)))
(define-action *things* ',name ,thing))))
(defmacro undefine-thing (name)
`(undefine-action *things* ,name))
(defun find-thing (name)
(do-things #'(lambda (thing)
(and (equal name (thing-name thing))
(defun add-things ()
(reduce '+ (do-things 'thing-number :collect)))