Re: Rebinding a recursive function

2011-12-02 Thread Roman Perepelitsa
2011/12/1 Stuart Sierra > > Do I understand correct that the only way to hook > > a recursive function without affecting other > > threads is to annotate the function with > > ^{:dynamic true} and call it via #'fact? > > If you want to you dynamic rebinding, yes. > > There are other possibilities

Re: Rebinding a recursive function

2011-12-01 Thread Stuart Sierra
> Do I understand correct that the only way to hook > a recursive function without affecting other > threads is to annotate the function with > ^{:dynamic true} and call it via #'fact? If you want to you dynamic rebinding, yes. There are other possibilities, however. Maybe you could pass the func

Re: Rebinding a recursive function

2011-12-01 Thread Roman Perepelitsa
Thanks for the reply, Nils. 2011/12/1 Nils Bertschinger > Hi Roman, > > as far as I understand, the Clojure compiler is doing some > optimizations for recursive functions to save the variable lookup. > This means that you have to explicitly write the recursive call as > (#'fact (dec n)) if you w

Re: Rebinding a recursive function

2011-12-01 Thread Nils Bertschinger
Hi Roman, as far as I understand, the Clojure compiler is doing some optimizations for recursive functions to save the variable lookup. This means that you have to explicitly write the recursive call as (#'fact (dec n)) if you want to dynamically rebind the function. Somehow this doesn't feel righ

[newbie] Rebinding a recursive function

2011-11-30 Thread Roman Perepelitsa
Hello, I'm trying to intercept each call to a recursive function in order to insert logging. It works on the first invocation but not on others. What am I missing? (defn fact [n] (if (< n 2) 1 (* n (fact (dec n) ; Given function f, returns another function that ; does the same as f