Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (ql:quickload :bordeaux-threads))
- (defmacro with-accessors* ((&rest accessors) object &body body)
- (let* ((vobject (gensym))
- (ll-process (bt:make-thread (lambda ()
- (multiple-value-list
- (com.informatimago.common-lisp.lisp-sexp.source-form:parse-body :locally body)))))
- (processes (mapcar (lambda (accessor)
- (bt:make-thread (lambda ()
- (list (if (listp accessor)
- (first accessor)
- accessor)
- `(,(if (listp accessor)
- (second accessor)
- accessor)
- ,vobject)))))
- accessors))
- (bindings (mapcar (function bt:join-thread) processes)))
- (destructuring-bind (docstrings declarations body) (bt:join-thread ll-process)
- (declare (ignore docstrings))
- `(let ((,vobject ,object))
- ,@declarations
- (symbol-macrolet ,bindings
- ,@body)))))
- (pprint (macroexpand-1 '(with-accessors* (x (color point-color)) pt
- (print color)
- (incf x))))
- (let ((#:g8884 pt))
- (symbol-macrolet ((x (x #:g8884)) (color (point-color #:g8884)))
- (print color)
- (incf x)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement