-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethod-combinations.lisp
39 lines (33 loc) · 1.37 KB
/
method-combinations.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(in-package :herrblog)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-method-combination with-start ()
((around (:around))
(before (:before))
(start (:start))
(primary () :required t)
(after (:after)))
(flet ((call-methods (methods)
(mapcar #'(lambda (method)
`(call-method ,method))
methods)))
(let ((form (if (or before after (rest primary) start)
`(multiple-value-prog1
(progn ,@(call-methods before)
(call-method ,(first start)
,(append (rest start) primary)))
,@(call-methods (reverse after)))
`(call-method ,(first primary)))))
(if around
`(call-method ,(first around)
(,@(rest around)
(make-method ,form)))
form))))
(define-method-combination reverse-append ()
((primary () :required t))
(if (endp (cdr primary))
`(the list (call-method ,(car primary)))
(cons 'append (mapcar #'(lambda (method) `(the list (call-method ,method)))
(reverse primary)))))
(define-method-combination stringify
:operator stringify
:identity-with-one-argument t)