Can I use Clojure's derive to create a hierarchy of my defrecord class types?

I would like to do something like:

(defrecord Base [])
(defrecord Person [])
(defrecord Animal [])

(derive Person Base)
(derive Animal Base)

(isa? Animal Person)

Is this possible?

Update:

I've since realized that this is not possible so I am doing something like this:

(defmulti type class)
(defmethod type Base [_] ::base )
(defmethod type Animal [_] ::animal )
(defmethod type Person [_] ::person )

Does this make sense or is there a better way?

6
задан Zubair 3 January 2011 в 17:56
поделиться