Perhaps you misunderstand protocols. Protocols don't support a hierarchy, thus you don't extend them; you have types implement/reify them. Any "extending" you do will be against a type.
Further, a protocol is a set of abstract function definitions; it is not a type, as such the notion of "functions that accept or return protocols" doesn't apply. For example, with the following: (defprotocol P (foo [x]) (bar-me [x] [x y])) It would make no sense to say some function "takes an instance of P", unless you're talking about the two functions, foo and bar-me. On May 15, 3:26 pm, Mikhail Kryshen <mikh...@kryshen.net> wrote: > Hi, > > I'm developing visualization component for some application. There is > a protocol to be extended to existing application problem domain > classes to specify how to visualize each type. The user can load > predefined implementations of the protocol or create custom > visualizations in REPL. > > The problem is that now I need several independent instances of the > visualizer (the kind of expandability almost free with well-designed > OO systems) running simultaneously in the context of the same > application each using different implementations of the protocol. > > I found that protocol is associated with a Var and extending the > protocol changes the root binding of that Var (not documented?). It > appears that protocol is not just a set of definitions but adds state > (current set of extenders and corresponding implementations) and > extend function does not modify the protocol structure itself nor does > it return new version of it but changes the state elsewhere. This > makes dynamic use of protocols (e.g. having functions that create, > accept or return protocols) problematic. > > Also it may be useful to have with-protocol macro that will bind > function vars to the implementations associated with the specified > instance of the protocol. > > -- > 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 > athttp://groups.google.com/group/clojure?hl=en -- 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