Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 1.26 KB

var.md

File metadata and controls

24 lines (21 loc) · 1.26 KB

var

(var name), #'name

Answers the var of a program definition: one object per name, printing #'ns/name. deref (or @) reads its root and calling it calls the root, so #'f stands in for f anywhere a function goes. A declared-but-never-defined name's var reads the unbound root (declare). meta answers what the newest definition above the site recorded: :arglists, the docstring as :doc, the name's metadata and attr map, :line/:column/:file, :name and :ns. A local is no var (the name resolves past it). A clojure.core name is the core var, printing #'clojure.core/name: its root is the core value and its metadata :name, :ns and a macro's :macro; a core var with no value here (#'*err*) is refused. A var of a library this front end implements as a lowering (#'clojure.string/join, #'s/trim through an alias, a referred #'union) is one too, its root the function value and its metadata :name and :ns.

(defn greet "Says hello." [who] (str "Hello, " who))
(println #'greet)                ; #'user/greet
(println (:doc (meta #'greet)))  ; Says hello.
(println (:arglists (meta #'greet))) ; ([who])
(println (#'greet "Ann"))        ; Hello, Ann
(println #'inc (#'inc 1))        ; #'clojure.core/inc 2