On Sep 4, 11:22 am, Krukow <karl.kru...@gmail.com> wrote: > I was thinking about the capability of changing production systems on > the fly. E.g. by having an accessible repl in a running production > system. > > If you have a bug in a function, you can fix it by re-def'ing it - > that is great. However, suppose you want to do a system upgrade where > you want to change several things. Now you could just re-def each var > one at a time, but this might produce an inconsistent program in the > interval where you have re-def'ed some but not all vars. > > This first thing you would want is sort-of a atomic update of all > vars, similarly to what is possible with refs. Is this possible > somehow? If not are there any techniques or best practices for these > "system upgrades"? > > /Karl
Hm, I don't think it's possible to have transactional updates involving multiple Vars, but you can always keep functions in Refs: (def foo (ref (fn foo [x] x))) then, because IRefs forward calls to their values, you can just do (foo 1) and it works. :) When you want to update multiple refs, all you should need to do is (dosync (ref-set foo newfn) (ref-set another-foo anothernewfn)) ... This approach requires a bit of manual work and discipline, but probably is worth investigating -- Jarkko --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---