Re: Adding primitive type hints to anonymous functions

2012-01-27 Thread Tassilo Horn
Ben Mabey writes: > Should a ticket be created for this then? Yes, please. And add a link to this discussion. Bye, Tassilo -- 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 pos

Re: Adding primitive type hints to anonymous functions

2012-01-27 Thread Ben Mabey
On 1/26/12 5:07 AM, Cedric Greevey wrote: On Thu, Jan 26, 2012 at 5:54 AM, Tassilo Horn wrote: Cedric Greevey writes: On Thu, Jan 26, 2012 at 2:28 AM, Tassilo Horn wrote: At least, it seems that (fn ^double [^double x] (+ x 0.5)) compiles to a class supporting primitive, unboxed calls. Ye

Re: Adding primitive type hints to anonymous functions

2012-01-26 Thread Cedric Greevey
On Thu, Jan 26, 2012 at 5:54 AM, Tassilo Horn wrote: > Cedric Greevey writes: > >> On Thu, Jan 26, 2012 at 2:28 AM, Tassilo Horn wrote: >>> At least, it seems that (fn ^double [^double x] (+ x 0.5)) compiles to a >>> class supporting primitive, unboxed calls. >> >> Yes. That was my conclusion al

Re: Adding primitive type hints to anonymous functions

2012-01-26 Thread Tassilo Horn
Cedric Greevey writes: > On Thu, Jan 26, 2012 at 2:28 AM, Tassilo Horn wrote: >> At least, it seems that (fn ^double [^double x] (+ x 0.5)) compiles to a >> class supporting primitive, unboxed calls. > > Yes. That was my conclusion also. But apparently the only way to get > the compiler to emit

Re: Adding primitive type hints to anonymous functions

2012-01-26 Thread Cedric Greevey
On Thu, Jan 26, 2012 at 2:28 AM, Tassilo Horn wrote: > At least, it seems that (fn ^double [^double x] (+ x 0.5)) compiles to a > class supporting primitive, unboxed calls. Yes. That was my conclusion also. But apparently the only way to get the compiler to emit such a call is by binding the fn t

Re: Adding primitive type hints to anonymous functions

2012-01-25 Thread Tassilo Horn
Cedric Greevey writes: Hi Cedric, > Actually, on further testing, I'm not sure that (def ^{Double/TYPE} > ...) is really working either, rather than boxing and then unboxing on > each call: > > user=> (def ^{:tag Double/TYPE} b (fn [^double x] (+ x 0.5))) > #'user/b > user=> (defn c ^double [^do

Re: Adding primitive type hints to anonymous functions

2012-01-25 Thread Cedric Greevey
On Wed, Jan 25, 2012 at 11:58 AM, Ben Mabey wrote: > On 1/25/12 2:25 AM, Tassilo Horn wrote: >> >> Hi again, >> >> I think, I got it.  I wrote a little helper function to print the >> metadata of a form: >> >> --8<---cut here---start->8--- >> (use 'clojure.walk)

Re: Adding primitive type hints to anonymous functions

2012-01-25 Thread Tassilo Horn
Ben Mabey writes: > Am I missing something, or does the new primitive support only apply > to bound functions? On the one hand, the docs don't mention such a restriction, but on the other hand, all examples given are always defn-defined. I tried to look into the compiler to find out, but that's

Re: Adding primitive type hints to anonymous functions

2012-01-25 Thread Ben Mabey
On 1/25/12 2:25 AM, Tassilo Horn wrote: Hi again, I think, I got it. I wrote a little helper function to print the metadata of a form: --8<---cut here---start->8--- (use 'clojure.walk) (defn print-meta ([form level] (prewalk (fn [x]

Re: Adding primitive type hints to anonymous functions

2012-01-25 Thread Tassilo Horn
Hi again, I think, I got it. I wrote a little helper function to print the metadata of a form: --8<---cut here---start->8--- (use 'clojure.walk) (defn print-meta ([form level] (prewalk (fn [x] (when-let [m (meta x)] (println "Lev

Re: Adding primitive type hints to anonymous functions

2012-01-24 Thread Tassilo Horn
Ben Mabey writes: Hi Ben, > Does the new primitive support added in 1.3 extend to anonymous > functions? I guess, it should. At least they are not disregarded... --8<---cut here---start->8--- user> (def with-def (fn ^float [^float x]

Adding primitive type hints to anonymous functions

2012-01-24 Thread Ben Mabey
Does the new primitive support added in 1.3 extend to anonymous functions? If so, I am doing something wrong because I can't get them to work: (definterface IPrimitiveTester (getType [^int x]) (getType [^long x]) (getType [^float x]) (getType [^double x]) (getType [^Object x])) (defty