daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CL-USER> (defmacro make-foo (id () &body body)
  2.   (let ((body-forms (loop :for form :in body :collect `(call-some-fn obj (make-instance ',(first form) ,@(cdr form))))))
  3.     `(let ((obj (make-instance 'object :id ,id)))
  4.        ,@body-forms)))
  5. MAKE-FOO
  6. CL-USER> (macroexpand '(make-foo xxx () (bar :a 1 :b 2) (baz :c 3 :d 4)))
  7. (LET ((OBJ (MAKE-INSTANCE 'OBJECT :ID XXX)))
  8.   (CALL-SOME-FN OBJ (MAKE-INSTANCE 'BAR :A 1 :B 2))
  9.   (CALL-SOME-FN OBJ (MAKE-INSTANCE 'BAZ :C 3 :D 4)))
  10. T
  11. CL-USER>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top