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 at
http://groups.google.com/group/clojure?hl=en

Reply via email to