Hi, I've been evaluating clojure with a bias around performance (I do a lot of numerical work). I don't need to the metal, but want to see that fundamental operations are comparable to java in performance and that performance can be had not at the expense of conciseness. In particular, I've noted that arithmetic such as:
(+ a b c d) is not equivalent to: (+ (+ (+ a b) c) d) in performance, because the former form applies + on a list or array form (I forget which). This is regardless of whether all of the above values have primitive type hints. At least this is what I observe in debugging (correct me if I am wrong). Could + and other operators be changed to a macro mapping rather than the current defn, mapping the argument list to a binary expression tree (+ (+ (+ ... instead of the list style application (I'm guessing yes, not being familiar with CL-style macros). Secondly, if one has code like: (let [ x (int a) y (int b)] (+ (* x 2) (* y 3) (* x y 5)) (* x 2) -> a function of (int, Object), as the literal 2 is not assumed to be a primitive type. This instead needs to be mapped to: (let [ x (int a) y (int b)] (+ (+ (* x (int 2)) (* y (int 3)) (* (* x y) (int 5)))) I don't know if type hints can be interrogated or known at the time of macro evaluation (I'm guessing not), but if so, would like to see that in such a macro. Automatically decorating literals that are used in the context of arithmetic with a primitive would make clojure a lot more usable for performance-concerned arithmetic. I think I saw mention that #^int (and other primitive types) will be supported at some point in argument declarations as well? Thanks Jonathan -- 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