Welcome! Please see the About page for a little more info on how this works.

0 votes
in Compiler by


(defrecord ABC [some-field])
(def ^:const abc (->ABC :some-value))
(println (class abc))

(defrecord XYZ [])
(def ^:const xyz (->XYZ))
(println (class xyz))

results in

"sx.clj.temp.ABC clojure.lang.PersistentArrayMap"

The XYZ seems to lose its class information, and is apparently stored as a simple map, instead of a record. I could not find the official specification of ^:const, but this behaviour seems incorrect to me, or at least inconsistent.

2 Answers

0 votes

Comment made by: alexmiller

Possibly related: CLJ-1093, CLJ-1575, CLJ-1460

0 votes
Reference: https://clojure.atlassian.net/browse/CLJ-2467 (reported by alex+import)