On Fri, Aug 12, 2011 at 10:17 AM, Stuart Sierra
<the.stuart.sie...@gmail.com> wrote:
>> Yes. The compiler probably optimized away the var lookup to an
>> embedded constant. You'll need to use an atom, as Baldridge suggested.
>
> The Clojure compiler doesn't optimize anything away. However, in a situation
> like this:
>
>     (defn foo [x y] ...)
>
>     (def bar (partial foo 1))
>
> The binding of `foo` is resolved when `bar` is defined, and never again
> thereafter. Changing the root binding of `foo` in this case would have no
> effect on `bar`.

That is what I meant, and from what I've heard, in 1.3 this behavior
extends to defn if the Var isn't defined with :dynamic true, that is,
(defn bar [x] (foo x)) will use a "baked-in" value of foo rather than
do a dynamic Var lookup. That's faster, but doesn't allow dynamic
binding to work, and presumably not alter-var-root either.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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

Reply via email to