Re: Primitive function boxes and unboxes result value

2012-11-21 Thread Gunnar Völkel
Of course. You are right. I did forget about the long constant. I hope your patch will be included in Clojure 1.5. -- 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 m

Re: Primitive function boxes and unboxes result value

2012-11-21 Thread Christophe Grand
Hi Gunnar, The only thing I fixed is related to recur (whose type was null and thus not unifiable with a primitive type). Concerning your fib2, I think the proble comes from the "then" being a long (1) and the else a double. Thus boxing is required to return either a long or double (well a Long a

Re: Primitive function boxes and unboxes result value

2012-11-21 Thread Gunnar Völkel
I think Cristophe is on the right path. But it is possible that there is another Bug concerning primitive functions. Consider the following two functions: (defn fib ^long [^long n] (if (<= n 1) 1 (+ (fib (dec n)) (fib (- n 2) (defn fib2 ^double [^double n] (if (<= n 1) 1 (+ (fib2 (dec n)

Re: Primitive function boxes and unboxes result value

2012-11-21 Thread Christophe Grand
I created an issue and attached a patch http://dev.clojure.org/jira/browse/CLJ- Now the 5 last lines of bytecode are: 52: goto9 55: goto61 58: pop 59: dload 5 61: dreturn Christophe On Tue, Nov 20, 2012 at 10:27 PM, Christophe Grand wrote: > I think CLJ-701 is

Re: Primitive function boxes and unboxes result value

2012-11-20 Thread Christophe Grand
I think CLJ-701 is about loop in non-terminal position. On Tue, Nov 20, 2012 at 6:30 PM, Andy Fingerhut wrote: > Any relationship to CLJ-701, other than similar symptoms? > > http://dev.clojure.org/jira/browse/CLJ-701 > > Andy > > On Nov 20, 2012, at 9:15 AM, Christophe Grand wrote: > > Hi, > >

Re: Primitive function boxes and unboxes result value

2012-11-20 Thread Andy Fingerhut
Any relationship to CLJ-701, other than similar symptoms? http://dev.clojure.org/jira/browse/CLJ-701 Andy On Nov 20, 2012, at 9:15 AM, Christophe Grand wrote: > Hi, > > It looks like, because of the recur, the compiler fails to notice that if > returns a primitive. > As far as I understand in

Re: Primitive function boxes and unboxes result value

2012-11-20 Thread Christophe Grand
Hi, It looks like, because of the recur, the compiler fails to notice that if returns a primitive. As far as I understand in Compiler.java, RecurExpr does not implement MaybePrimitiveExpr and thus causes on canEmitPrimitive the surrounding IfExpr to return false. Someone to confirm this analysis?

Re: Primitive function boxes and unboxes result value

2012-11-20 Thread Gunnar Völkel
I can add some additional information. I compiled the fibonacci example with double and long type hints: (defn fib ^long [^long n] (if (<= n 1) 1 (+ (fib (dec n)) (fib (- n 2) (defn fib ^double [^double n] (if (<= n 1) 1 (+ (fib (dec n)) (fib (- n 2) The one with ^long works as expe