On Wed, May 30, 2012 at 3:26 PM, Gerrard McNulty <gerrard.mcnu...@gmail.com> wrote: > I see a lot of clojure libraries use the pattern where an implicit > variable is stored as a dynamic variable. A good example is > clojure.java.jdbc:
I wouldn't say it's a "good example". It's certainly an example of this pattern. > What do I do if I have to instantiate two things that uses the same > dynamic binding at the same time. Using the java.jdbc example, what > if I wanted to run multiple selects from db-1 and insert each result > into db-2? Do I need keep calling (sql/with-connection db-2 ...) > after each select from db-1? No, you'd need to doall on the selects from db-1 and lift the results out and then pass them into inserts on db-2. Your example is partly why this practice of binding dynamic variables as "implicit" variables is poor: it doesn't compose. Coming soon to clojure.java.jdbc: an API where you can pass the db connection directly into every operation. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- 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