On Mon, Mar 14, 2011 at 11:15 PM, Daniel Solano Gomez <cloj...@sattvik.com> wrote: > This method works fairly well, and you can even use it to define > protocols for types you don't control, such as classes from a Java API. > > If you need some more complicated form of dispatch for polymorphism, > there is the multimethod approach.
And if you need more complex still, you can embed function references in some fields of your objects and call those. This resembles OO methods in that the functions are members of the objects, but you needn't have inheritance; you can have ad hoc objects and arbitrary mixins; and you can have any kind of assignment or function resolution you want. And you can still have top level functions that call your member functions. Really, Lisp's first-class functions cause a panoply of options to open up for modeling objects-with-behavior and polymorphism and let you use styles ranging from fairly OO to nearly pure FP even to procedural (via, for instance, long let bindings that do stepwise computations), or mix and match them to suit. Use protocols and records when they fit well; otherwise, investigate multimethods and explicit use of function pointers. -- 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