What’s meaning difference between var and quote in Clojure? For example, (var a) and (quote a).
The official site has the below documents, but what’s the difference of var object and the value for the symbol? I am confused.
(var symbol)
The symbol must resolve to a var, and the Var object itself (not its value) is returned
(quote a)returns a symbol (clojure.lang.Symbol) – it effectively does the same as'a. It’s worth reading a bit more about the Clojure reader to find out a bit more about symbols. Example:(var a)returns the var (clojure.lang.Var) represented by the symbol a in the current namespace. You’ll get an error if a is not defined in the current namespace. Example:That’s the technical definition – but here’s the intuition behind it: a symbol is a name, which can be used to look up a var in a given namespace. A var itself is a kind of reference that can hold any kind of Clojure value. So a symbol identifies a var which contains a value.