2010/5/5 Meikel Brandmeyer <m...@kotka.de>: > Hi Laurent, > > On Wed, May 05, 2010 at 10:12:52PM +0200, Laurent PETIT wrote: > >> > The question with the new style is: to which filter does f refer to? >> > >> > (ns some.name.space) >> > >> > (defn f [pred x] (filter pred x)) ; core filter? >> > >> > (defn filter [pred x] ...) >> >> I bet on core filter, since compilation will hard link to the fn (for >> clojure.core) or resolve the symbol into a var, which at compile time >> will still be the var pointing to core. >> >> /me crosses fingers and hopes he finally "got things" :-) > > What happens when re-evaluating (parts) of the namespace? Eg. during > development in the Repl?
Let's see in practice: lpe...@lpetit-laptop:~/projects$ mkdir -p tmp lpe...@lpetit-laptop:~/projects$ echo "(ns foo) (def f \"f in foo \")" > tmp/foo.clj lpe...@lpetit-laptop:~/projects$ cat tmp/foo.clj (ns foo) (def f "f in foo ") lpe...@lpetit-laptop:~/projects$ java -cp clojure/clojure.jar:tmp/ clojure.main Clojure 1.2.0-master-SNAPSHOT user=> (ns bar (:use foo)) nil bar=> (defn before [] (str "before redefining: " f)) #'bar/before bar=> (before) "before redefining: f in foo " bar=> (def f "f in bar") WARNING: f already refers to: #'foo/f in namespace: bar, being replaced by: #'bar/f #'bar/f bar=> (defn after [] (str "after redefining: " f)) #'bar/after bar=> (after) "after redefining: f in bar" bar=> (before) "before redefining: f in foo " bar=> (defn before [] (str "before redefining: " f)) #'bar/before bar=> (before) "before redefining: f in bar" bar=> So I was right ..., and simulating reloading 'before uses the new context when in REPL. So those warnings are to be taken very seriously into account. But it's not worse than writing a new version of a macro and forgetting to recompile all the code depending directly or indirectly on the macro ... > There are pitfalls one has to be aware of. I still like the warning > instead of the error. I also am very interested in this new behaviour. Time will tell, though. -- 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