Hello Clojurers! I'm enjoying testing Java code with Clojure and it's been a lot of fun so far. Coming from Scheme, the transit is comfortable. However, I encountered a big surprise when I nested def's and used them with a proxy:
(defn new* [] (def i (atom 0)) (proxy [Object] [] (toString [] (str i)))) (defn new*-let [] (let [i (atom 0)] (proxy [Object] [] (toString [] (str i))))) (defn mew* [] (def i (atom 0)) i) (pprint (list (new*) (new*) (new*) (new*-let) (new*-let) (new*-let) (mew*) (mew*) (mew*))) I expected to see a list of 3 * 3 elements, each element a unique Atmon instance. But from it's printout, the first three instances are identical. Shouldn't all versions of new* produce their own version of a lexically-scoped i (like in Scheme), or am I missing something? Are nested defs and lets not supposed to behave identically? Note that the non-proxied version, mew*, makes nested def work like let. Could this be a proxy-bug? K. -- 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