On 29.10.2009, at 13:48, John Harrop wrote: > One issue with using multimethods is the resolution overhead. I > don't think the JIT can optimize this to the extent it can optimize > a normal polymorphic Java call.
That's worth exploring - while keeping in mind that the JIT improves all the time. > So you might want to use a Java interface for this instead, and > Clojure's Java interop with macros to wrap a nice Clojury API around > it. Maybe. For now I would consider this premature optimization. The big negative impact of using a Java interface is the impossibility to work with existing Java classes, such as Colt arrays. They would have to be wrapped in another object layer just for implementing the interface. > A second problem is boxing of primitives, and a third is > noncontiguous storage. The Java for the nonsparse stuff should > probably use and expose Java arrays of primitives. I can see a role both for an implementation based on Clojure vectors and for one using Java arrays. With a multimethod interface, both can coexist. > If you can live without runtime polymorphism, having only compile- > time polymorphism, the polymorphism can move back to the Clojure > side but live in a macro; Indeed. One could implement a polymorphic interface in one namespace and a compile-time polymorphic interface in another namespace, making it possible to switch easily between the two. What is nice about Clojure is that many of these implementation decisions can be changed later on without modifying the client-side API. Konrad. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---