Advertisement
Guest User

Untitled

a guest
Aug 4th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1.  
  2. cl-user> (cat "/tmp/g.lisp")
  3. (defun generate-val (obj key) `(jsown:val ,obj ,key))
  4.  
  5. (defmacro with-jsown-vals (obj vals &body body)
  6. "Provides the passed jsown values as local variables within the scope to be used."
  7. `(let ,(mapcar #'(lambda (key) (list (intern (string-upcase key)) (generate-val obj key))) vals)
  8. ,@body))
  9.  
  10. (pprint (macroexpand-1 '(with-jsown-vals *js* (list "b" "a") (format t "~A" a))))
  11. ; No value
  12. cl-user> (load "/tmp/g.lisp")
  13.  
  14. (let ((list (jsown:val *js* list)) (b (jsown:val *js* "b")) (a (jsown:val *js* "a"))) (format t "~A" a))
  15. #P"/private/tmp/g.lisp"
  16. cl-user>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement