Placing this form in a user
namespace top-level:
(set! *default-data-reader-fn* tagged-literal)
leads to the following error when starting a REPL (with Clojure 1.11.1):
Exception in thread "main" Syntax error macroexpanding at (user.clj:9:1).
at clojure.lang.Compiler.load(Compiler.java:7665)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:368)
at clojure.lang.RT.maybeLoadResourceScript(RT.java:364)
at clojure.lang.RT.doInit(RT.java:486)
at clojure.lang.RT.init(RT.java:467)
at clojure.main.main(main.java:38)
Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *default-data-reader-fn* with set
at clojure.lang.Var.set(Var.java:226)
at user$eval148.invokeStatic(user.clj:13)
at user$eval148.invoke(user.clj:13)
at clojure.lang.Compiler.eval(Compiler.java:7194)
at clojure.lang.Compiler.load(Compiler.java:7653)
... 6 more
Evaluating the same form after the REPL has started up works fine, though.
Further note that placing this form in the user
top-level instead works fine:
(alter-var-root #'*default-data-reader-fn* (constantly tagged-literal))
Why does set!
not work here? If there is a good reason for this, I suggest to update https://clojure.org/reference/reader#_default_data_reader_function to mention it.