bradford cross <bradford.n.cr...@gmail.com> writes: > First item of business - there are no operators, operators are functions. > > I think the Clojure way to do this is via multimethods: > http://clojure.org/multimethods > > I might just be naive, but it seems like more of core would need to be > implemented as multimethods in order to do this. > > Has this come up before?
Yes, the general consensus is that basic math needs to be as fast as possible, even at the expense of some flexibility. Others have proposed making things like +/-/</> multimethods by default and having a "fast math" library that can override the method definitions with primitives that work only with numerics. This would be great IMHO since it means things like (> "abc" "def") would work as you'd expect, but people who needed the speed boost could still get it. (Make it right, then make it fast, as they say.) If you want to override + on a per-namespace basis, you can use a refer-clojure :exclude clause in your ns macro that defines the namespace: (ns my-struct-adding-namespace (:refer-clojure :exclude [empty])) (defn + [x y] ;; body goes here ) This means that anyone requiring your namespace will have to either exclude core's + or your + unless you make yours private. -Phil --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---