Thanks, I had seen that ::Foo use and was a bit confused. Now it all makes sense.
It would still be nice to have an auto-generated name?-style predicate in deftype, I think. -Per On Fri, Mar 19, 2010 at 7:44 PM, Meikel Brandmeyer <m...@kotka.de> wrote: > 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. > -- 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.