Oh, and so it's not too miserable to understand what my example is doing, it's just binding *a* to :new using with-bindings. ;)
I know it looks like a Rube Goldberg way to do it, but it's a distilled, abstract example taken from: http://github.com/tjg/tjg-utils/blob/master/src/tjg-utils.clj#L92 All the best, Tayssir On Feb 19, 2:56 pm, Tayssir John Gabbour <[email protected]> wrote: > 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
