I'm trying to create a macro that will splice in some additional
elements to a structure. If I have an input struture like so:
(p (s (c foo bar)) (s (c baz qux)))
I'd like to be able to do (splice grp layout (rest my-data)) and have
it return:
((s grp layout (c foo bar)) (s grp layout (c baz qux)))
Here's the closest I came:
(defmacro splice [a b & body]
(let [sbody (map (fn [f] (list* (first f) a b (rest f))) body)]
`~sbody))
but it's just returning an empty list, anyone see what I;m doing
wrong?
In context: I'm trying to create a nice wrapper around GroupLayout,
I'd ike to be able to set up (in Java or Clojure) a Map<String,
Component> and then use something like
(defmacro create-form [#^Container container #^Map components &
body]
(let [layout (GroupLayout. container)]
(.setLayout container layout)
...))
to turn a form this this
(create-form container component-map
(horizontal (p (s (c "foo" "bar")) (s (c "baz" "qux"))))
(vertical (s (p "foo" "baz") (p "bar" "qux"))))
with p creating a parallel group, s creating a sequential group, and c
containing a list of component names to add (looked up from component-
map).
Any thought on this idea would also be appreciated.
Cheers,
Ian.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---