Written by
Aaron Bell
on
on
How I see Clojure quoting
quote
-ing leaves most things alone except for what could refer to something else.
(type (quote ())) ;;=> PersistentList$EmptyList
(type (quote [])) ;;=> PersistentVector
(type (quote {})) ;;=> PersistentArrayMap
(type (quote #{})) ;;=> PersistentHashSet
(type (quote max)) ;;=> Symbol
(type (quote 1)) ;;=> Long
(type (quote :a)) ;;=> Keyword
(type (quote nil)) ;;=> nil
(map type (quote (1 2 3))) ;;=> (Long Long Long)
(map type (quote (max min whoa)));;=> (Symbol Symbol Symbol)
Ticks called quote reader macros allow you to write concisely:
(type '()) ;;=> PersistentList$EmptyList
(type '[]) ;;=> PersistentVector
...
(map type '(max min whoa));;=> (Symbol Symbol Symbol)
Quoting lets you build lists for the Clojure evaluator. Building lists for the evaluator is the whole idea behind the macro (also see this and this), except that with quotes you can turn the form into a listable thing anywhere, not just via the macro’s arguments.