Hi Doug: > we can generalize predicate dispatching even further. Instead of methods having predicates over the list of arguments to the generic function application, we can give them predicates over join point objects, which contain the generic function, the list of arguments, the enclosing method, and the previous join point object. Whenever a generic function is applied, a join point is created, and a method is selected that is applicable to that join point and has precedence over the other applicable methods. -- Back to your example attached below: Here traverse is the generic function. When it is invoked on a company: (set! sum 0) (call-next-method) sum) and then (traverse (company-name x)) (traverse (company-depts x))) are executed. So what are: what to do, and when to do it? "what to do" is the above. "when to do it" is : when traverse is at company. So the abstract story is: Doug's approach to computing (DAC): Given is a list of generic things to do, a particular thing to do, determine list of generic things that are applicable and perform them in order which will lead to other particular things to do. DAC sounds a generally useful problem solving technique. There seems a connection to Prolog-like systems? In DJ, the generic things to do are: to traverse, and the visitor methods a particular thing to do: to process a specific object determine list of generic things that are applicable: traversal, visitor method -- Karl (define-struct company (name depts)) (define-struct department (name emps)) (define-struct employee (name salary)) (define (make-company-traversal) (define-gf traverse) (add-method! traverse (x) #t) (add-method! traverse ((pair? x)) (traverse (car x)) (traverse (cdr x))) (add-method! traverse ((company? x)) (traverse (company-name x)) (traverse (company-depts x))) (add-method! traverse ((department? x)) (traverse (department-name x)) (traverse (department-emps x))) (add-method! traverse ((employee? x)) (traverse (employee-name x)) (traverse (employee-salary x))) traverse) (define (make-summing traversal container? content? get-value) (define sum 0) (add-around! (and (eq? (jp-gf jp) traversal) (container? (car (jp-args jp)))) (set! sum 0) (call-next-method) sum) (add-around! (and (eq? (jp-gf jp) traversal) (content? (car (jp-args jp)))) (set! sum (+ sum (get-value (car (jp-args jp))))) (call-next-method)) traversal) (define sum-salaries (make-summing (make-company-traversal) company? employee? employee-salary)) (define count-employees (make-summing (make-company-traversal) company? employee? (lambda (x) 1))) (define (average-salary company) (floor (/ (sum-salaries company) (count-employees company)))) (define company (make-company "SICP Tech" (list (make-department "Computer" (list (make-employee "Ben Bitdiddle" 60000) (make-employee "Alyssa P. Hacker" 40000) (make-employee "Cy D. Fect" 35000) (make-employee "Lem E. Tweakit" 25000) (make-employee "Louis Reasoner" 30000))) (make-department "Administration" (list (make-employee "Oliver Warbucks" 150000) (make-employee "DeWitt Aull" 25000))) (make-department "Accounting" (list (make-employee "Eben Scrooge" 75000) (make-employee "Robert Cratchet" 18000)))))) Need good way to modularize generic information.