评论者: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>`