recur doesn't complain when autoboxing fails?
= (defn abc [] 3) #'ants/abc = (loop [a 1] (when (= 1 a) (recur (abc NO_SOURCE_FILE:2 recur arg for primitive local: a is not matching primitive, had: Object, needed: long Auto-boxing loop arg: a nil = (loop [a 1] (when (= 1 a) (recur (long (abc) nil = (loop [a 1] (when (= 1 a) (recur *(var defn)*))) NO_SOURCE_FILE:2 recur arg for primitive local: a is not matching primitive, had: Object, needed: long Auto-boxing loop arg: a nil How was that boxed into long? :O since this wouldn't work: = (loop [a 1] (when (= 1 a) (recur (long (var defn) ClassCastException clojure.lang.Var cannot be cast to java.lang.Number clojure.lang.RT.longCast (RT.java:1151) = (long (var defn)) ClassCastException clojure.lang.Var cannot be cast to java.lang.Number clojure.lang.RT.longCast (RT.java:1151) = (loop [a 1] (cond (not (= 1 a)) a :else (recur (var defn NO_SOURCE_FILE:5 recur arg for primitive local: a is not matching primitive, had: Object, needed: long Auto-boxing loop arg: a *#'clojure.core/defn* Shouldn't it err saying that it can't autobox into long? or am I missing the meaning here? it does say that it had Object and it needed long, does that autoboxing make it Long or long? apparently it just leaves it as is:*#'clojure.core/defn * Any thoughts on this? = (loop [a 1] (cond (not (= 1 a)) a :else (recur (abc NO_SOURCE_FILE:5 recur arg for primitive local: a is not matching primitive, had: Object, needed: long Auto-boxing loop arg: a 3 = (loop [a 1] (cond (not (= 1 a)) a :else (recur (long (abc) 3 this makes sense. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: recur doesn't complain when autoboxing fails?
On Sun, Apr 28, 2013 at 5:46 AM, AtKaaZ atk...@gmail.com wrote: = (defn abc [] 3) #'ants/abc = (loop [a 1] (when (= 1 a) (recur (abc NO_SOURCE_FILE:2 recur arg for primitive local: a is not matching primitive, had: Object, needed: long Auto-boxing loop arg: a nil The compiler isn't telling you it will need to box your recur arg into a long, but that it will be boxing your initial loop arg into an Object. Think of the message as Maybe you intended `a` to be a primitive local, but since you passed `recur` a who-knows-what, it won't be. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: recur doesn't complain when autoboxing fails?
Thank you very much, I see it now. 1. boxing means from primitive to object; unboxing is from object to primitive (I disregarded this for some reason) 2. it does say the loop arg not the recur arg: Auto-boxing loop arg: a On Sun, Apr 28, 2013 at 3:38 PM, John D. Hume duelin.mark...@gmail.comwrote: On Sun, Apr 28, 2013 at 5:46 AM, AtKaaZ atk...@gmail.com wrote: = (defn abc [] 3) #'ants/abc = (loop [a 1] (when (= 1 a) (recur (abc NO_SOURCE_FILE:2 recur arg for primitive local: a is not matching primitive, had: Object, needed: long Auto-boxing loop arg: a nil The compiler isn't telling you it will need to box your recur arg into a long, but that it will be boxing your initial loop arg into an Object. Think of the message as Maybe you intended `a` to be a primitive local, but since you passed `recur` a who-knows-what, it won't be. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.