Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defmacro with-gethash-accessors (bindings &body body)
- `(macrolet ,(mapcar (lambda (b)
- (if (symbolp b)
- (let ((sym (gensym))
- (keyword (intern (string b) :keyword)))
- `(,b (,sym) `(gethash ,,keyword ,,sym))))) bindings)
- ,@body))
- ;; target input:
- (with-gethash-accessors (x y)
- (x object)
- (y object))
- ;; desired output:
- (macrolet ((x (#:gensym1) `(gethash :x ,#:gensym1))
- (y (#:gensym2) `(gethash :y ,#:gensym2)))
- (x object)
- (y object))
- ;; actual output:
- (macrolet ((x (#:gensym1) `(gethash ,:x ,#:gensym1))
- (y (#:gensym2) `(gethash ,:y ,#:gensym2)))
- (x object)
- (y object))
Add Comment
Please, Sign In to add comment