Good examples of defmulti polymorphism

2009-06-02 Thread Glen Stampoultzis
I'm used to polymorphism in OO systems where everything in driven from inheritance hierarchy. Clojures defmulti style polymorphism seems powerful but has left me wondering how to most effectively use it. I'm looking for some good real world examples of how people have used polymorphism in

Re: Good examples of defmulti polymorphism

2009-06-02 Thread Konrad Hinsen
On 02.06.2009, at 12:01, Glen Stampoultzis wrote: I'm used to polymorphism in OO systems where everything in driven from inheritance hierarchy. Clojures defmulti style polymorphism seems powerful but has left me wondering how to most effectively use it. I'm looking for some good real

Re: Good examples of defmulti polymorphism

2009-06-02 Thread Stuart Halloway
Hi Glen, (1) Real-world example: I use polymorphism on the types of two different arguments to define implicit conversions: (defmulti coerce (fn [dest-class src-inst] [dest-class (class src-inst)])) (defmethod coerce [java.io.File String] [_ str] (java.io.File. str)) (defmethod

Re: Good examples of defmulti polymorphism

2009-06-02 Thread Richard Newman
Some work in which I'm currently engaged uses ad hoc hierarchies for dispatching on a handler and either a message method or a method and response code. In the realm of HTTP clients -- imagine that the response arrives as a method invocation -- the equivalent would be writing something like

Re: Good examples of defmulti polymorphism

2009-06-02 Thread Glen Stampoultzis
Some good examples from everyone. Thank you. 2009/6/3 Richard Newman holyg...@gmail.com Some work in which I'm currently engaged uses ad hoc hierarchies for dispatching on a handler and either a message method or a method and response code. In the realm of HTTP clients -- imagine that the

Re: Good examples of defmulti polymorphism

2009-06-02 Thread Glen Stampoultzis
Actually considering I'm currently writing a game in clojure that contains a lot of state this _is_ a good real world example for me. Thanks very much Laurent. 2009/6/3 Laurent PETIT laurent.pe...@gmail.com Hi, Here is an example of the implementation of the Visitor design pattern in