syntax | since v0.0-1853 | in clojure | Edit |
Inserts an evaluated form inside of a ``` syntax quote`` template.
`(foo ~x)
=> (cljs.user/foo 123)
(if x is 123)(def foo 1)
`~foo
;;=> 1
`(def foo ~foo)
;;=> (def cljs.user/foo 1)
(defn- read-unquote
[rdr comma opts pending-forms]
(if-let [ch (peek-char rdr)]
(if (identical? \@ ch)
((wrapping-reader 'clojure.core/unquote-splicing) (doto rdr read-char) \@ opts pending-forms)
((wrapping-reader 'clojure.core/unquote) rdr \~ opts pending-forms))))
(defn- macros [ch]
(case ch
\" read-string*
\: read-keyword
\; read-comment
\' (wrapping-reader 'quote)
\@ (wrapping-reader 'clojure.core/deref)
\^ read-meta
\` read-syntax-quote ;;(wrapping-reader 'syntax-quote)
\~ read-unquote
\( read-list
\) read-unmatched-delimiter
\[ read-vector
\] read-unmatched-delimiter
\{ read-map
\} read-unmatched-delimiter
\\ read-char*
\% read-arg
\# read-dispatch
nil))