Hi,
I'm having problems with nested syntax-quotes, or something.
This works fine:
(use 'clojure.contrib.macro-utils)
(def *a* nil)
;; good
(defmacro my-macro [& body]
`(let [name# {#'*a* :new}]
(macrolet [(~(symbol 'with-my-macrolet) [& body#]
(concat (list 'with-bindings 'name#)
body#))]
~...@body)))
user> (my-macro (with-my-macrolet *a*))
=> :new
But the macrolet is a little hard to read. My attempts to use nested
syntax-quotes fail miserably:
;; uh-oh...
(defmacro my-macro [& body]
`(let [name# {#'*a* :new}]
(macrolet [(~(symbol 'with-my-macrolet) [& body#]
`(with-bindings ~name# ~...@body#))]
~...@body)))
(my-macro (with-my-macrolet *a*))
=>
| user$eval__1980$eval__1982
| [Thrown class java.lang.InstantiationException]
Any ideas?
Thanks,
Tayssir
PS - For the curious, here's where I'm using this:
http://github.com/tjg/tjg-utils/blob/master/src/tjg-utils.clj#L92
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en