Hi, On Mar 19, 12:09 pm, Per Vognsen <per.vogn...@gmail.com> wrote:
> It looks like there isn't a way to get at the class behind a deftyped > type other than constructing a dummy instance and taking its class, > because the generated class has a gensymmed name. I was doing > something where I needed to test when something was an instance of a > deftype, so I added this to the `(do ...) block in deftype's > implementation: > > (defn ~(symbol (str name "?")) [x#] > (instance? ~classname x#)) > > It would also be nice if the class itself was exposed under some > standardized name, e.g. (symbol (str ~name "-class"))). Any reason > this isn't done right now? I would not rely on "class" but on "type", which will return the type tag of the type. Unfortunately the tag does currently not work with "instance?". (defn general-instance? [t o] (isa? (type o) t)) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.