On 17 май, 12:07, Laurent PETIT <laurent.pe...@gmail.com> wrote: > Yes, > > as David wrote, > > What you're describing is not single-dispatch-based polymorphism (e.g. > like in java), it's double dispatch (because you want to dispatch to > the implementation of the protocol function based on both the type and > another parameter which may be totally dynamic, or materialized -when > serialized- by some key in the configuration - spring bean name, > etc.).
That makes sense. It looks like I was trying to avoid explicit double-dispatch by manipulating the protocol at runtime. Is it abuse of dynamic features of Clojure? > Protocols are based on a single dispatch mechanism, as classical > "class based" languages (e.g. Java) are. > > When you write "kind of expandability almost free with well-designed > OO systems", I guess this design implies some kind of implementation > of the Strategy pattern, or more probably Delegation pattern. What I was actually talking about is the possibility to avoid global state and being able to extend existing implementation to multiple instances without much refactoring. Protocols and multimethods both have global state. From what I saw in Clojure source protocols are manipulated by changing root binding of associated var, and multimethods are actually mutable functions changed by defmethod (I see inconsistency here). There is no standard way to create multimethod or protocol without binding it to global var. Why is it possible to create non-global function but not multimethod? -- Mikhail -- 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