Hi Clojurians! Please could somebody explain the code highlighted expression below to me? (Adapted from *The Joy of Clojure*, listing 8.9)
(defmacro with-resource [bindings close-fn & body] > `(let ~bindings > (try > ~@body > (finally > (~close-fn ~(bindings 0)))))) I've changed the name of the variable from binding to bindings as I originally thought this was calling the function binding! I've also removed the redundant do loop. Using macroexpand-1 on the code yields the following: user> (macroexpand-1 '(with-resource [x 1] #(println %))) > (clojure.core/let [x 1] (try (finally ((fn* [p1__1605#] (println > p1__1605#)) x)))) It seems like the highlighted expression is indexing into the let vector at position 0. Neat trick, but this doesn't seem to work when multiple variables are being bound by the let. So how would one modify with-resource to call close-fn with multiple variables? Regards, Ralph -- 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