Reputation: 47071
Why (doc str)
but (meta #'str)
?
In the latter one, why is the #'
necessary, which isn't in the first one?
Upvotes: 3
Views: 123
Reputation: 33657
doc
is a macro which internally applies #'
i.e var
to the passed name, hence you don't need to pass the var itself to it. meta
is a function and hence it needs the var itself to be passed otherwise the value of the var will get passed to it if you use just the name of the var (as done in doc
)
Upvotes: 5
Reputation: 4629
#'
is the reader macro, #'str expands to (var str), return the Var object, see doc:
user> (doc meta)
-------------------------
clojure.core/meta
([obj])
Returns the metadata of obj, returns nil if there is no metadata.
Upvotes: 0