I'm trying to make a macro my-macro so that the last statement in:

  (def my-map {:a 2})
  (defn process-a-map [arg] ...)
    ; Turns maps into corresponding vectors.
    ; (process-a-map my-map) returns ['*foo* :blah].

  (my-macro a-map ; Last statement
    (do-something))

expands to:

  (binding [*foo* :blah] (do-something))
  ; process-a-map was called on a-map

But I'm getting stuck because a-map always gets passed into my-macro
as a symbol.

  (defmacro my-macro [a-map & forms] ; Naive implementation
    `(binding ~(vec (process-a-map a-map)) ~...@forms))

Here, when my-macro is called, process-a-map receives the symbol 'a-
map, rather than what I want—a-map's value, {:a 2}. What can I do? Is
this impossible for macros to deal with?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to