Occasionally when looking at other people's Clojure code, I see a function defined via defn
and then called using the var-quote syntax, e.g.:
user> (defn a [] 1)
#'user/a
user> (a) ; This is how you normally call a function
1
user> (#'a) ; This uses the var-quote syntax and produces the same result
1
For the life of me I can't figure out the difference between these two ways of calling a function. I can't find anything in the evaluation documentation to say what happens when the operator of a call is a var that might suggest why the second form would be preferred. They both seem to respond in the same to binding
assignments and syntax-quoting.
So, can somebody please provide a code sample that will illustrate the difference between (a)
and (#'a)
above?
Edit: I know that var-quote can be used to get to a var that's shadowed by a let
lexical binding, but that doesn't seem to be the case in the code that I'm looking at.