I don't know the details of your particular use, but for a general solution to the resource management problem, maybe Stuart Sierra's component<https://github.com/stuartsierra/component>system would work for you.
marc On Sun, Apr 27, 2014 at 10:30 AM, Peter B. West <peter.b.w...@gmail.com>wrote: > > On 27 Apr 2014, at 7:40 pm, Carlo Zancanaro <carlozancan...@gmail.com> > wrote: > > > I'm struggling to understand the problem that you're actually trying to > > solve. The solution that you are proposing doesn't seem like an elegant > > solution to any problem, so could you elaborate on what you're trying to > > do? > > > > http://dev.clojure.org/display/design/Resource+Scopes > > It doesn't take long to run into this problem. > > From http://stuartsierra.com/2013/03/29/perils-of-dynamic-scope > > "Resource management is one concurrency bugaboo that Clojure developers > have not managed to crack. Various attempts have been made: you can see the > artifacts in wiki and mailing list discussions of Resource Scopes. So far, > no solution has been found that doesn’t just shift the problem somewhere > else." > > I have no ambitions to solve the general problem; just to find a workable > solution for my own use. > > > On Fri, Apr 25, 2014 at 08:58:42AM -0700, Peter West wrote: > >> One interesting thing about intern is that it will create *or find* a > var, > >> setting its root binding. That means that var circumvents the > immutability > >> of a var, doesn't it? I thought vars were supposed to be immutable. > > > > Vars are not immutable. Clojure has four datatypes which are used for > > mutability: Agents, Atoms, Refs and Vars. As I said originally, your > > function is mutating the global scope, whether by using `intern` or by > > using `def`, and this is generally not a good idea. There is (almost), a > > better solution than mutating the global state. > > I mistook the intention of binding as being the only way to modify a var. > I was influenced by the XSLT notion of "variable." Thanks for clearing up > that misconception. > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.