On Thu, May 26, 2011 at 7:54 PM, Andreas Kostler <
andreas.koestler.le...@gmail.com> wrote:

> Hi guys,
> I'm kinda lost as to what's going on here...With clojure-1.2.0
>
> (defn bin-search [v k c]
>  (loop [l 0
>         h (dec (count v))]
>    (if (> l h) false
>        (let [m (quot (+ l h) 2)
>              m-v (v m)]
>          (cond (> m-v k) (recur (inc m) h)
>                (> k m-v) (recur l (dec m))
>                :else m)))))
>
> This bombs out with:
> java.lang.IllegalArgumentException: recur arg for primitive local: h must
> be matching primitive
>
> With 1.3.0-master-SNAPSHOT it works fine. Any ideas what I'm doing wrong?
> Andreas
>

In 1.2.0 count was inlined, thus returned a primitive causing dec to return
a primitive. But l does not have type hint - thus (+ l h) returns a boxed
number - so m is also boxed. You recur with m in h's place which is
primitive. Thus the error.

David

David

-- 
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

Reply via email to