[CLJ-394] Add marker Interfaces for defrecords and deftypes plus boolean test fns Created: 05/Jul/10 Updated: 01/Mar/13
|Fix Version/s:||Release 1.6|
|Patch:||Code and Test|
Sometimes one would like to know if an object is an instance of a deftype or a defrecord.
|Comment by Assembla Importer [ 24/Aug/10 12:04 AM ]|
Converted from http://www.assembla.com/spaces/clojure/tickets/394
|Comment by Steve Miner [ 20/Apr/12 1:55 PM ]|
As of Clojure 1.3, there are marker interfaces named clojure.lang.IType and clojure.lang.IRecord. You can use instance? with those interfaces. I'm not sure if they're actually documented for public use, but they seem to work as expected in 1.3 and 1.4. If you want record?, you can try this:
(defn record? [rec] (instance? clojure.lang.IRecord rec))
|Comment by Devin Walters [ 20/Oct/12 6:38 PM ]|
See attached code and test. I'm unsure as to whether or not the location of the tests and predicates make sense. Please let me know if I should move them elsewhere.