类型成员

类

; Clojure 没有静态成员:由命名空间保存值和函数

; 类型常量
(def max-connections 3)

; 类型的“字段”
(def host (atom "10.0.0.1"))
(def port (atom 0))

; 类型的“方法”
(defn get-connection [] (str @host ":" @port))

(reset! port 52)
(println (get-connection))  ; 10.0.0.1:52

(reset! host "10.0.0.3")
(println (get-connection))  ; 10.0.0.3:52
(println max-connections)