On Wed, Dec 29, 2010 at 16:10, David Nolen <[email protected]> wrote: > On Wed, Dec 29, 2010 at 6:59 AM, B Smith-Mannschott <[email protected]> > wrote: >> >> (In Clojure 1.3-alpha-3, which I happen to have lying around): >> >> double is a function, not a class. So, Clojure responds: >> >> CompilerException java.lang.IllegalArgumentException: Unable to >> resolve classname ... >> >> (defn f [^double x] x) ; does not work because double is not a class >> (defn f [^Double x] x) ; does work. Double is a class >> (defn f [^Double/TYPE x] x) ; does not work. Double/TYPE is not a class, >> ; though it stands in for the java type >> 'double' >> ; for reflection. >> >> Short answer: use ^Double >> >> // Ben > > That's not the problem, and that will give you boxed numbers. > You can't cast the contents of a sequence to a primitive type. And no more > than four arguments may be primitive.
Ah. I stand corrected: - (defn f [^double x] x) Does in fact work against clojure-1.3.0-master-SNAPSHOT (built today). - (defn f [^double a ^double b ^double c ^double d ^double e] (* a b c d e)) Does not work, as you explained. "CompilerException java.lang.IllegalArgumentException: fns taking primitives support only 4 or fewer args" It does, however, work in 1.2.0, but that only makes sense as this is related to Rich's striving to better support primitives for performance reasons and that work began with 1.3. - (defn f [[^double x]] x) The compiler (1.3) does not complain about this, though I can't say what kind of code it generates. (I suspect it boxes x, but I don't know.) What did you mean by "You can't cast the contents of a sequence to a primitive type"? // Ben -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
