In clojure 1.1, all calls were dynamic, meaning that you could redefine a function at the REPL and it would be included in the running program automatically. This was also nice for things like dotrace.

In clojure 1.2, many calls seem to be statically linked, and if I want to replace a function, Sometimes, I have to find all the places where it's called and put #' in front of them.

Worse, I can't predict where I'll need to do this.

Is it possible to go back to the old default of dynamic linking? Maybe if you needed the extra iota of speed you could switch it back on for the production app, but for development I much prefer the 1.1 behaviour.

I'm hoping for some sort of compiler option like *warn-on-reflection*.

Edit:

I'm confused about what's going on. More specifically, here are two functions. I prefer the behaviour of the second. How can I make the first one behave like the second, as I believe it used to do in 1.1?

user> (clojure-version) "1.2.0" user> (defn factorial[n] (if (< n 2) n (* n (factorial (dec n))))) #'user/factorial user> (require 'clojure.contrib.trace) user> (clojure.contrib.trace/dotrace (factorial) (factorial 10)) TRACE t1670: (factorial 10) TRACE t1670: => 3628800 user> (defn factorial[n] (if (< n 2) n (* n (#'factorial (dec n))))) #'user/factorial user> (clojure.contrib.trace/dotrace (factorial) (factorial 10)) TRACE t1681: (factorial 10) TRACE t1682: | (factorial 9) TRACE t1683: | | (factorial 8) TRACE t1684: | | | (factorial 7) TRACE t1685: | | | | (factorial 6) TRACE t1686: | | | | | (factorial 5) TRACE t1687: | | | | | | (factorial 4) TRACE t1688: | | | | | | | (factorial 3) TRACE t1689: | | | | | | | | (factorial 2) TRACE t1690: | | | | | | | | | (factorial 1) TRACE t1690: | | | | | | | | | => 1 TRACE t1689: | | | | | | | | => 2 TRACE t1688: | | | | | | | => 6 TRACE t1687: | | | | | | => 24 TRACE t1686: | | | | | => 120 TRACE t1685: | | | | => 720 TRACE t1684: | | | => 5040 TRACE t1683: | | => 40320 TRACE t1682: | => 362880 TRACE t1681: => 3628800 3628800

Edit (to the whole question, and a change of title):

Joost points out below that what's actually going on here is that the self call in factorial is being optimized away. I can't see why that would be done, since you can't do that many recursive self calls without blowing the stack, but it explains the observed behaviour. Perhaps it's something to do with anonymous self-calls.

The original reason for my question was that I was trying to write http://www.learningclojure.com/2011/03/hello-web-dynamic-compojure-web.html, and I got irritated with the number of places i had to type #' to get the behaviour I expected. That and the dotrace made me think that the general dynamic behaviour had gone and that the on the fly redefining, which works in some places, must be done with some clever hack.

In retrospect that seems a strange conclusion to jump to, but now I'm just confused (which is better!). Are there any references for all this? I'd love to have a general theory of when this will work and when it won't.