Yields the unevaluated form. See https://clojure.org/special_forms for more information.
;; ' is the shortcut for quote user> (= 'a (quote a)) true ;; quoting keeps something from being evaluated user> (quote (println "foo")) (println "foo") => *clojure-version* {:major 1, :minor 5, :incremental 0, :qualifier "RC17"} => (quote) nil => (quote 1) 1 => (quote 1 2 3 4 5) ; this worked in Clojure 1.0 through 1.7 but stopped working in 1.8 1 => quote CompilerException java.lang.RuntimeException: Unable to resolve symbol: quote in this context, compiling:(NO_SOURCE_PATH:1:42)
;; Proof that ' is just a syntactic sugar for quote: user=> (macroexpand ''(1 2 3)) (quote (1 2 3)) ;; Two ' must be used because reader processes and removes the first one
;; Quote returns the argument you pass it, without evaluation. So: ;; In the expression `(quote 42)` the argument is the number 42 and... user> (= (quote 42) 42) true ;; ... it is returned without any evaluation and... user> (= (type (quote 42)) (type 42) java.lang.Long) true ;; ... as expected, without changing it's type. ;; In the expression `(quote (quote 42))` the argument is the list of two ;; elements `(quote 42)` ... user> (= (quote (quote 42)) (list (read-string "quote") (read-string "42"))) true ;; ... and it is returned without any evaluation and... user> (= (type (quote (quote 42))) (type (list "1st-elem" "2nd-elem")) clojure.lang.PersistentList) true ;; ... again, without changing it's type.
;; Since clojure 1.9, if all keys in a map have the same namespace qualifier ;; then the common namespace become the prefix of the map. user> 'org.clojure/clojure org.clojure/clojure user> '{org.clojure/clojure 3} #:org.clojure{clojure 3} ;; expecting {org.clojure/clojure 3} but not user> '{org.clojure/clojure 3 :k 8} {org.clojure/clojure 3, :k 8} ;; Because of the keys' different namespaces ;; If you want to avoid second case then flip *print-namespace-maps* temporally. user> (binding [*print-namespace-maps* false] (pprint '{org.clojure/clojure 3})) {org.clojure/clojure 3} nil ;; 'This is not a thing about quote. It is about map with key of namespaced keyword.' ;; (@ShiTianshu's reply is quoted from below link) ;; To know the detail reason, go to the below link and see the reply of @didibus. ;; https://clojureverse.org/t/the-quote-special-form-behaves-strangely-on-maps/4879#post_2
Quote gives you the unevaluated form. That is:
user=> '(foo bar baz)
Will not attempt to evaluate foo as a function but rather just return the data structure as is (with the three symbols unevaluated).
I found this blog post interesting: http://blog.8thlight.com/colin-jones/2012/05/22/quoting-without-confusion.html
Cheers
The blog-post linked above has moved to https://8thlight.com/insights/quoting-without-confusion