Why is the ^ metadata symbol not working?

The metadata documentation claims to be ^{:hi 10} 'xequivalent (with-meta 'x {:hi 10}), but I don't see it.

Evaluating the following with repl,

(binding [*print-meta* true]
  (prn ^{:hi 10} 'x)
  (prn (with-meta 'x {:hi 10})))

prints the following, which indicates that the first case does not receive the attached metadata.

x
^{:hi 10} x

Am I doing something wrong?

+4
source share
1 answer

^ , , . 'x , ; (quote x) '. ^{:hi 10} 'x, (quote x), x:

user> (set! *print-meta* true)
user> (prn (read-string "'x"))
(quote x)
user> (prn (read-string "^{:hi 10} 'x"))
^{:hi 10} (quote x)

:

 user> (prn (eval (read-string "^{:hi 10} 'x")))
 x

, ^ ', :

user> (prn (read-string "'^{:hi 10} x"))
(quote ^{:hi 10} x)
user> (prn '^{:hi 10} x)
^{:hi 10} x
+4

All Articles