Ah, wrapping the initial `acc` val in `(num)` works...

On 20 June 2015 at 15:05, Karsten Schmidt <i...@toxi.co.uk> wrote:
> I just encountered a problem with recur, I never came across before.
> Am trying to generate `coll-reduce` implementations over primitive
> nd-arrays and get bitten by special type restrictions on recur args if
> they're an initially primitive value (using 1.7.0-RC2):
>
> (loop [acc (aget ^bytes a 0) i 1]
>   (if (< i 2)
>     (recur (+ acc (aget ^bytes a i)) (inc i))))
>
> CompilerException java.lang.IllegalArgumentException:
> recur arg for primitive local: acc is not matching primitive, had:
> long, needed: byte
>
> Is there any way to avoid this compiler error, since I can't predict
> what type the reduction fn (`+` in the example) will return...
>
> Usually one wants of course as little boxing as possible, but here're
> I'd very much like to, but don't know how to do so with that initial
> `acc` val...



-- 
Karsten Schmidt
http://postspectacular.com | http://thi.ng | http://toxiclibs.org

-- 
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/d/optout.

Reply via email to