评论由: 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 Can't set!: set-me from non-binding thread clojure.lang.Var.set (Var.java:230)
user>`