2017-03-06 11:00:18 -05:00
|
|
|
(load "functions.lisp")
|
2017-03-01 16:33:06 -05:00
|
|
|
|
2017-03-10 15:08:42 -05:00
|
|
|
;; This is based on the dlambda macro presented in "Let Over Lambda" by Doug Hoyte.
|
2017-03-08 11:14:44 -05:00
|
|
|
|
2017-03-13 14:43:31 -04:00
|
|
|
(defmacro dlambda (&rest methods)
|
|
|
|
(let ((arguments (gensym)))
|
2017-03-07 16:27:11 -05:00
|
|
|
|
2017-03-13 14:43:31 -04:00
|
|
|
`(lambda (&rest ,arguments)
|
|
|
|
(case (first ,arguments)
|
|
|
|
,@(mapcar
|
|
|
|
(lambda (method)
|
|
|
|
`(,(first method)
|
|
|
|
(apply (lambda ,@(rest method))
|
|
|
|
,(if (equal t (first method))
|
|
|
|
arguments
|
|
|
|
`(rest ,arguments)))))
|
|
|
|
methods)))))
|