I've been wondering about having let over defn, I have the following concerns -
1. Not recommended in the docs http://clojure.org/special_forms#Special%20Forms--%28def%20symbol%20init?%29 says - Using def to modify the root value of a var at other than the top level is usually an indication that you are using the var as a mutable global, and is considered bad style. 2. Source is required again: (ns a) (println "a---1") (let [b (atom 0)] (println "a---2") (defn op1 [] (swap! b inc)) (defn op2 [] (swap! b dec))) user=> (require 'a) a---1 a---2 nil user=> (a/op1) 1 user=> (require 'a :reload) a---1 a---2 nil user=> (a/op1) 1 user=> But this is a more generic problem - do solve this you can - (defonce ___ (let [b (atom 0)] (println "a---2") (defn op1 [] (swap! b inc)) (defn op2 [] (swap! b dec)))) user=> (require 'a) a---1 a---2 nil user=> user=> (a/op1) 1 user=> (a/op1) 2 user=> (require 'a :reload) a---1 nil user=> (a/op1) 3 user=> But as you can see the code doesn't look too pretty. -- 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