(no title)
ambulancechaser | 5 years ago
((juxt type identity) (clojure.edn/read-string "x"))
[clojure.lang.Symbol x]
It seems that the reader returns symbols just fine.ambulancechaser | 5 years ago
((juxt type identity) (clojure.edn/read-string "x"))
[clojure.lang.Symbol x]
It seems that the reader returns symbols just fine.
kazinator|5 years ago
The documentation for EDN says that "nil, booleans, strings, characters, and symbols are equal to values of the same type with the same edn representation." The only way two symbol values can be equal is if they are actually same symbol, I would hope.
john-shaffer|5 years ago
Why is this important? Specifically, why do symbols need to be interned?
In Clojure, "Two symbols are equal if they have the same namespace and symbol name." In general, "Clojure’s = is true when comparing immutable values that represent the same value, or when comparing mutable objects that are the identical object." [1]
[1] https://clojure.org/guides/equality
reitzensteinm|5 years ago
With that said, I always thought symbols would intern, but that's not the case. It is true with keywords, however.
(identical? (clojure.edn/read-string "x") 'x) => false
(= (clojure.edn/read-string "x") 'x) => true
(identical? (clojure.edn/read-string ":x") :x) => true