评论由:joegallo撰写
当然,Alex -- 这里是今早刚刚运行的一个repl示例。
`
; nREPL 0.1.7
user> (def ^:dynamic set-me nil)
'user/set-me
user> (defn try-to-set [] (binding [*set-me* 1] (doall (pcalls #(if (thread-bound? #'set-me) (set! set-me (inc set-me)))))))
'user/try-to-set
user> (try-to-set)
IllegalStateException: Cannot set! set-me from non-binding thread clojure.lang.Var.set (Var.java:230)
user>`