Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CL-USER> (defmacro make-foo (id () &body body)
- (let ((body-forms (loop :for form :in body :collect `(call-some-fn obj (make-instance ',(first form) ,@(cdr form))))))
- `(let ((obj (make-instance 'object :id ,id)))
- ,@body-forms)))
- MAKE-FOO
- CL-USER> (macroexpand '(make-foo xxx () (bar :a 1 :b 2) (baz :c 3 :d 4)))
- (LET ((OBJ (MAKE-INSTANCE 'OBJECT :ID XXX)))
- (CALL-SOME-FN OBJ (MAKE-INSTANCE 'BAR :A 1 :B 2))
- (CALL-SOME-FN OBJ (MAKE-INSTANCE 'BAZ :C 3 :D 4)))
- T
- CL-USER>
Add Comment
Please, Sign In to add comment