var
명명된 var 생성하기
명명된 var는 다른 참조 타입들과는 달리 그 이름으로 평가하면 자동적으로 역참조가 수행되어 #'
가 앞에 붙게 된다
@
나 deref를 직접 호출하지 않아도 된다
(def favorite-color :green) #'user/favorite-color favorite-color ;=> :green
그래서 값이 아닌 바인딩된 var를 참조하려면 #'
또는 동일한 의미의 특수 구문 var를 사용해야 한다
(var favorite-color) ;=> #'user/favorite-color
var 상태
초기화 방법 | (resolve 'x) | (bound? #'x) | (thread-bound? #'x) |
---|---|---|---|
(def x) | #'user/x | false | false |
(def x 5) | #'user/x | true | false |
(binding [x 7] …) | #'user/x | true | true |
(with-local-vars [x 9] …) | nil | true | true |