是串列的賦值的, 所以後面的binding可以用前面binding的值, 而 是不行的.
,,,,,,,,, and.要使用這些binding的函數會被這些binding的值影響的。比如給*out*一個新的binding會改變println函數的輸出終端。
, 和的用法:
; clojure connect to mysql; ithomer.net; 2013.12.10(ns myClojure.syntax.binding)(def ^:dynamic v 1) ; v is a global binding (defn f1 [] (println "f1: v =" v)) ; global binding of 1 (defn f2 [] (println "f2: before let v =" v) ; global binding (let [v 2] ; creates local binding v that shadows global one (println "f2: in let, v =" v) ; local binding of 2 (f1)) ; of 1 (println "f2: after let v =" v)) ; global binding of 1 (defn f3 [] (println "f3: before binding v =" v) ; global binding of 1 (binding [v 3] ; same global binding with new, temporary value (println "f3: in binding, v =" v) ; global binding of 3 (f1)) ; of 3 (println "f3: after binding v =" v)) ; global binding of 1 (defn f4 [] (def v 4) ; changes the value of the global binding (println "f4: after binding v =" v) ; of 4 (f1)) ; of 4 (f2)(f3)(f4)(println "after calling f4, v =" v) ; of 4
f2: before let v = 1f2: in let, v = 2f1: v = 1f2: after let v = 1f3: before binding v = 1f3: in binding, v = 3f1: v = 3f3: after binding v = 1f4: after binding v = 4f1: v = 4after calling f4, v = 4
Clojure入門教程
Clojure 基本文法