ClojureDocs

Nav

Namespaces

The symbol must resolve to a var, and the Var object itself (not its value)
is returned. The reader macro #'x expands to (var x). See
http://clojure.org/special_forms for more information.
3 Examples
;;getting meta-data for a defined symbol (as opposed to what it's pointing to.

user=> meta
#<core$meta clojure.core$meta@2e257f1b>

user=> (var meta)
#'clojure.core/meta

;; Reader shortcut for var is #'
user=> #'meta
#'clojure.core/meta

user=> (meta (var meta))
{:ns #<Namespace clojure.core>, :name meta, :file "clojure/core.clj", :line 178, :arglists ([obj]), :doc "Returns the metadata of obj, returns nil if there is no metadata.", :added "1.0"}
=> *clojure-version*
{:major 1, :minor 5, :incremental 0, :qualifier "RC17"}
=> var
;CompilerException java.lang.RuntimeException: Unable to resolve symbol: var in this context, compiling:(NO_SOURCE_PATH:1:42) 
=> (var)
;CompilerException java.lang.NullPointerException, compiling:(NO_SOURCE_PATH:1:1) 
=> (var 1)
;CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:1:1) 
=> (var defn)
#'clojure.core/defn
=> (var defn 1 2 3 4)
#'clojure.core/defn
user> (def a 1)
#'user/a

user> (def b (var a))
#'user/b

user> (alter-var-root (var a) inc)
2

user> (alter-var-root b inc)
3

user> (deref b)
3
See Also

Returns the metadata of obj, returns nil if there is no metadata.

Added by boxie

Returns a Symbol with the given namespace and name. Arity-1 works on strings, keywords, and vars.

Added by boxie

Return true if x is a Symbol

Added by boxie

Returns true if v is of type clojure.lang.Var

Added by boxie

binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the ...

Added by eric

binding => var-symbol temp-value-expr Temporarily redefines Vars while executing the body. The ...

Added by eric

Temporarily redefines Vars during a call to func. Each val of binding-map will replace the root v...

Added by eric

Assignment special form. When the first operand is a field member access form, the assignment is to ...

Added by eric

Sets the value in the var object to val. The var must be thread-locally bound.

Added by AtKaaZ

Gets the value in the var object

Added by AtKaaZ

varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to ...

Added by AtKaaZ
0 Notes
No notes for var