On Nov 28, 11:14 am, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> Am 28.11.2011 um 20:10 schrieb Brent Millare:
>
> > I need to verify if an object implements a protocol. Looking at the source 
> > code, I noticed that protocol objects act as a map, and has the key :impls. 
> > From this is a map I can look up a class to see if there are functions. The 
> > resulting code is:
>
> > (defn implements? [protocol obj]
> >   (boolean ((:impls protocol) (class obj))))
>
> > The problem with this is this relies on implementation details. I would 
> > like to do this safely. I noticed that in clojure.core there is a private 
> > function implements?. This appears to do what I want. Is it possible to 
> > make this public? What is the motivation for keeping it private?
>
> You want satisfies? ?
>
> Sincerely
> Meikel

satisfies? is more correct than his implementation, too. :impls
doesn't contain an entry for classes which actually implement the
generated interface, only for those which extend the protocol after
definition.

-- 
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

Reply via email to