As of Clojure 1.3 you need to mark things you with to re-bind
explicitly as dynamic:

(defn ^:dynamic twice [x]
  ...)


On Tue, Oct 30, 2012 at 7:42 PM, Satoru Logic <satorulo...@gmail.com> wrote:
> Hi, all.
>
> I am reading Clojure in Action.
>
> In the "scope" section of Chapter3, there are examples like this:
>
> defn twice [x]
>   (println "original function")
>   (* 2 x))
>
> (defn call-twice [y]
>   (twice y))
>
> (defn with-log [function-to-call log-statement]
>   (fn [& args]                                
>
>     (println log-statement)
>     (apply function-to-call args)))
>
>                               
>
> (call-twice 10)
>
>                                       
>
> (binding [twice (with-log twice "Calling the twice function")]
>    (call-twice 20))
>
>                               
>
> (call-twice 30)
>
>
> When I tried to run this code in repl, I got the following exception:
>
>
>> IllegalStateException Can't dynamically bind non-dynamic var: user/twice
>> clojure.lang.Var.pushThreadBindings (Var.java:353)
>
>
> Is the book wrong or I'm running with the wrong version of clojure?
>
>                               
>                       
>               
>       
>
> --
> 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

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