hmmm.... macro question:

; here's a macro that assembles many puts. It serves no purpose to me
(and doesn't even make sense in its current form). It's just something
I hit playing around and learning macros.

(defmacro doto-putter [x y xs]
  `(doto (java.util.HashMap.)
     (.put ~x ~y)
       ~@(for [[k v] xs]`(.put ~k ~v))))

user=>  (doto-putter "c" 3 {"a" 1 "b" 2})
#<HashMap {b=2, c=3, a=1}>

however:

=>(defn omg [x y xs](doto-putter x y xs))
CompilerException java.lang.IllegalArgumentException: Don't know how
to create ISeq from: clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:2)

I'm thinking the issue seems to be that it's not resolving xs because
this works:

(defmacro doto-putter [x y]
  `(doto (java.util.HashMap.)
     (.put ~x ~y)
       ~@(for [[k v]{"a" 1 "b" 2}]`(.put ~k ~v))))

user=> (defn omg [x y](doto-putter x y))
#'user/omg

user=>(omg "c" 3)
#<HashMap {b=2, c=3, a=1}>

what am I missing? None of my other macros have this problem.

-- 
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