24 lines
621 B
Common Lisp
24 lines
621 B
Common Lisp
(load "functions.lisp")
|
|
|
|
;; This is based on the dlambda macro presented in "Let Over Lambda" by Doug Hoyte.
|
|
|
|
(let
|
|
((add-method-clause
|
|
(lambda (method)
|
|
(cons (first method)
|
|
(list
|
|
(cons 'apply
|
|
(cons (cons 'lambda (rest method))
|
|
(list
|
|
(if (equal t (car method))
|
|
'arguments
|
|
'(rest arguments))))))))))
|
|
|
|
(defmacro dlambda (&rest methods)
|
|
(cons 'lambda
|
|
(cons '(&rest arguments)
|
|
(list
|
|
(cons 'case
|
|
(cons '(first arguments)
|
|
(mapcar add-method-clause methods))))))))
|