syntax | since v0.0-1853 | in clojure | Edit |
The ability to evaluate forms at reader-time should be ignored in ClojureScript.
#=...
Allows the reader to evaluate the following form.
This feature is carried from tools.reader is not intended for use in ClojureScript, though it works for basic forms not using symbols.
#=123
;;=> 123
#="foo"
;;=> foo
(def foo 1)
#='foo
;;=> 1
The following is the output for the ClojureScript compiler on the JVM:
#=(+ 1 2)
;; java.lang.RuntimeException: Unable to resolve symbol: + in this context
#=(clojure.core/+ 1 2)
;;=> 3
(defn- read-eval
[rdr _ opts pending-forms]
(when-not *read-eval*
(err/reader-error rdr "#= not allowed when *read-eval* is false"))
(eval (read* rdr true nil opts pending-forms)))
(defn- dispatch-macros [ch]
(case ch
\^ read-meta ;deprecated
\' (wrapping-reader 'var)
\( read-fn
\= read-eval
\{ read-set
\< (throwing-reader "Unreadable form")
\" read-regex
\! read-comment
\_ read-discard
\? read-cond
\: read-namespaced-map
\# read-symbolic-value
nil))