Yes you need to provide an implementation of the protocol for the type directly or a parent interface.
What the initial author says is that you can do that on any type, even on an outside library, without changing the initial Type source code or recompile it. You can do that at runtime and because protocol are namespace, there is no risk to replace by error an already existing method with the same name in the class. In java to do that you would need to modify the class itself or make a proxy through inheritence or implementing a common interface. On Oct 26, 1:42 am, Brent Millare <brent.mill...@gmail.com> wrote: > I recently read the article > > http://www.colourcoding.net/blog/archive/2011/10/25/clojure-is-a-get-... > > and it mentions in the "Better than a better java" section, that "Compojure > defines a protocol called Renderable that allows you to specify how return > types get converted into Ring responses. Now, you could apply an adapter > pattern in most languages to link these two up. In Clojure, you can > declare that a type implements a protocol and it*just works*. You don’t > need to extend the type; you don’t need to monkey patch it; you don’t need > to introduce a proxy object under your control." > > What does the author mean by "don't need to extend the type" but only need > to "declare that a type implements a protocol?" > > I am familiar with extend, and extend-type, or extend-protocol, but not > JUST declaring a type implements a protocol and it magically works. From > what I know, you always have to specify the implementation, even if the > implementation is simply delegating it to some other function. > > Best, > Brent -- 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