On 26.02.2009, at 01:51, Rich Hickey wrote: > You raise interesting issues and I'd like to explore them further. I'm > not sure the issues you have with type-tag-or-class dispatch are all > that prohibitive. In any case, I've added a type function that returns > the :type metadata or the class if none:
Thanks, that helps a lot! With a built-in universal dispatching function, most of my problems should be solved. Another useful function to have would be (defn type-instance? "Evaluates x and tests if it is an instance of the type or class t. Returns true or false" [t x] (identical? t (type x))) for type-based dispatching inside a function. > I'm not sure the mechanism you are using (actual Class types) allows > for any more overloading - Class is a single slot too, after all. True, but the number of classes is not limited. Java programmers can live with a single class hierarchy, so it can't be too bad. But Clojure's hierarchies are definitely more flexible. > A bigger problem with the mechanism you've chosen is its dependence on > some implementation details. I haven't promised, e.g. that every fn > generates a unique class type. I know, but as I said, my current implementation is just a proof of concept. It is not viable for production use for a variety of reasons. I was planning to replace it by something based on gen-class and proxy, but I will first try to get away with the new type function. 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 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 -~----------~----~----~----~------~----~------~--~---