The reader reference docs state "tagged literals are Clojure’s implementation of edn tagged elements."
But the two are different in at least one regard: a symbol produced by a tagged literal will be resolved, but a symbol produced by a tagged element and read by clojure.edn/read-string
will not.
This means you can get different output if you read EDN containing a given tag vs. if you use the same tag to produce a literal in your source.
Example:
data_readers.cj
{example/symbolize clojure.core/symbol}
Then:
user> (edn/read-string {:readers {(quote example/symbolize) clojure.core/symbol}}
"#example/symbolize\"hello\"")
hello
user> #example/symbolize "hello"
Syntax error compiling at (*cider-repl clojure/foragr:localhost:46533(clj)*:0:0).
Unable to resolve symbol: hello in this context
user>
Is there any particular reason for this discrepency? Is there a scenario where it would be good to resolve symbols from a tagged literal? And if so, why not do the same from tagged elements and edn/read-string
?