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.
signature.asc
Description: Message signed with OpenPGP using GPGMail