I agree it looks like a type-hinting issue, but since ^bytes x is
reader-expanded to ^{:tag 'bytes} x, I don't see that change making
any difference. I'd be more inclined to try ^"[B" instead, to avoid
the possibility of var resolution.

I don't get the last point. He wants it to be type-hinted so a generic
arr= won't work unless you tell it what type to use; and the compiler
is not set up to support arbitrary-arity inlining, so he would have to
pick some fixed set of arities to support. The set #{2} seems like a
reasonable choice to me, since there's no builtin for comparing
multiple arrays.

On Jan 2, 11:27 am, David Nolen <dnolen.li...@gmail.com> wrote:
> I suspect this has more to do with type-hinting inside a macro. Did you try
> adding :tag metadata to those symbols?
>
> As a side note I do find this approach a bit strange. Why not just define a
> generic arr= that with multi-arity inlining?
>
> On Mon, Jan 2, 2012 at 1:43 PM, Sam Ritchie <sritchi...@gmail.com> wrote:
> > Hey all,
>
> > I'm writing a function called barr= that looks just like clojure.core/=,
> > but uses java.util.Arrays/equals instead of equiv. To speed up the function
> > I tried adding type hints to both the function definition and the
> > 2-argument inlined version. Type hinting the inline function threw an
> > exception that makes me think the compiler is interpreting Here's the gist:
> >https://gist.github.com/1551640
>
> > Type hints on the function definition work great:
>
> > (defn barr=
> >   ([x] true)
> >   ([^bytes x ^bytes y]
> >      (java.util.Arrays/equals x y))
> >   ([x y & more]
> >      (if (barr= x y)
> >        (if (next more)
> >          (recur y (first more) (next more))
> >          (barr= y (first more)))
> >        false)))
>
> > But hinting the inline version causes an exception:
>
> > (defn barr=
> >   {:inline-arities #{2}
> >    :inline (fn [x y] `(let [^bytes x# ~x
> >                                 ^bytes y# ~y]
> >                        (java.util.Arrays/equals x# y#)))}
> >   ([x] true)
> >   ([^bytes x ^bytes y]
> >      (java.util.Arrays/equals x y))
> >   ([x y & more]
> >      (if (barr= x y)
> >        (if (next more)
> >          (recur y (first more) (next more))
> >          (barr= y (first more)))
> >        false)))
>
> > ;; CompilerException java.lang.IllegalArgumentException: Unable to resolve
> > classname:
> > ;; clojure.core/bytes, compiling:(NO_SOURCE_PATH:54)
>
> > The compiler seems to be interpreting this type hint as a var. Are type
> > hints not allowed inside of inline definitions for some reason?
>
> > Cheers,
> > --
> > Sam Ritchie, Twitter Inc
> > 703.662.1337
> > @sritchie09
>
> > (Too brief? Here's why!http://emailcharter.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 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