I'm fairly new to Clojure and I'm not sure I completely understand the difference between apostrophe and backtick in Clojure.
(def x 5)
;; Question 1
(+ x x) ;; evaluates to 10
'(+ x x) ;; evaluates to (+ x x)
`(+ x x) ;; evaluates to (clojure.core/+ user/x user/x)
;; Question 2
`(~+ ~x ~x) ;; evaluates to (#<core$_PLUS_ clojure.core$_PLUS_@32ee28a9> 5 5)
- Correct me if I'm wrong, but it seems to me that apostrophe prevents all symbols (i.e + and x) from resolving to their respective var's, whereas backtick allows the symbols to resolve to their var's (but doesn't evaluate to the values within the var). Is this accurate?
- What exactly does the unquote symbol (~) do here? Is it eval'ing the var to its actual value (i.e. the + symbol to the function object and the x symbol to the number object)? If you could explain this in terms of Clojure's READ-COMPILE-EVAL phases, that would be helpful as well.