On Jul 7, 4:08 am, Roman Roelofsen <roman.roelof...@googlemail.com> wrote: > * Parametrization of "function groups" * > > Lets say I have a bunch of functions that provide database operations > (read, write, delete, ...). They all share information about the > database the operate on. In an OO language, I would define these > methods in the same class and an instance variable would define the > database. The advantage is, that the caller side does not need to be > aware of the database name. I can create an instance somewhere and > pass around the object.
For this particular case i just create a simple macro with-db, that behind the scenes passes a premade db connection info into with- connection macro. So the actiual usage looks very simple and clean: (with-db (sql-val ["select name from author where id = ?" 123])) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---