Advertisement
Guest User

Untitled

a guest
Aug 4th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. (eval-when (:compile-toplevel :load-toplevel :execute)
  2. (ql:quickload :bordeaux-threads))
  3.  
  4.  
  5. (defmacro with-accessors* ((&rest accessors) object &body body)
  6. (let* ((vobject (gensym))
  7. (ll-process (bt:make-thread (lambda ()
  8. (multiple-value-list
  9. (com.informatimago.common-lisp.lisp-sexp.source-form:parse-body :locally body)))))
  10. (processes (mapcar (lambda (accessor)
  11. (bt:make-thread (lambda ()
  12. (list (if (listp accessor)
  13. (first accessor)
  14. accessor)
  15. `(,(if (listp accessor)
  16. (second accessor)
  17. accessor)
  18. ,vobject)))))
  19. accessors))
  20. (bindings (mapcar (function bt:join-thread) processes)))
  21. (destructuring-bind (docstrings declarations body) (bt:join-thread ll-process)
  22. (declare (ignore docstrings))
  23. `(let ((,vobject ,object))
  24. ,@declarations
  25. (symbol-macrolet ,bindings
  26. ,@body)))))
  27.  
  28. (pprint (macroexpand-1 '(with-accessors* (x (color point-color)) pt
  29. (print color)
  30. (incf x))))
  31.  
  32. (let ((#:g8884 pt))
  33. (symbol-macrolet ((x (x #:g8884)) (color (point-color #:g8884)))
  34. (print color)
  35. (incf x)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement