Eric a écrit :
> He said that I should use clojure.core/list instead of #'list.  That
> is, to reference it with a fully-qualified name.  But my understanding
> is that binding still changes clojure.core/list withing the binding
> form.  Here, from my REPL:
>
> (let [list 10]
>   (binding [list +]
>     (clojure.core/list 1 2 3)))
>
> => 6
>
> So, my question is this: what is the difference/relationship between
> #' and the fully-qualified name?
>   

There's not so much difference when they are used in function position 
but in argument position they behave differently.
Below is an example (from 
http://clj-me.blogspot.com/2009/01/shadowing-global-names.html) where 
you can see that with a name (I could have used a qualified name) you 
pass the current value of the binding while with #' you pass the var 
itself and those values will behave differently if they are "leaked" 
outside of the calling scope (eg: sent to another thread or agent, used 
in a lazy sequence or a delay, stored in a mutable box etc.)

(def a (map str (range 10)))
(def b (map #'str (range 10)))
(take 5 a)
/("0" "1" "2" "3" "4")/
(take 5 b)
/("0" "1" "2" "3" "4")/
(binding [str identity] (doall a))
/("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")/
(binding [str identity] (doall b))
/("0" "1" "2" "3" "4" *5 6 7 8 9*)/



Christophe

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