Can you explain this more? In the second example, it's unhappy because a vector is not a primitive array?
And I don't understand the idea of a "soft hint". It looks like "this may be ints", but that's true without the hint. So what is the hint doing? On Saturday, July 20, 2013 2:31:50 AM UTC-7, Michał Marczyk wrote: > > Also, ^foo-style hints are "soft hints" in the following sense: > > (let [^ints xs [1 2 3]] xs) ; no complaint from compiler or RTE > > In contrast, ints & Co. demand that the casts be correct: > > (let [xs (ints [1 2 3])] xs) ; ClassCastException > > > On 20 July 2013 11:29, Michał Marczyk <michal....@gmail.com <javascript:>> > wrote: > > More complete example: > > > > (defn get-some-ints [] > > (int-array [1 2 3])) > > > > (set! *warn-on-reflection* true) > > > > ;; causes a reflection warning > > (let [xs (get-some-ints)] > > (aget xs 0)) > > > > ;; do not cause reflection warnings > > (let [xs (ints (get-some-ints))] > > (aget xs 0)) > > > > (let [xs ^ints (get-some-ints)] > > (aget xs 0)) > > > > (let [^ints xs (get-some-ints)] > > (aget xs 0)) > > > > Cheers, > > Michał > > > > > > On 20 July 2013 11:25, Michał Marczyk <michal....@gmail.com<javascript:>> > wrote: > >> I think it's more about clojure.core/{ints,longs,...}. These are > >> basically tools for removing reflection: > >> > >> (let [xs (ints (get-some-ints))] > >> (aget xs 0)) ; no reflection here thanks to the cast > >> > >> Cheers, > >> Michał > >> > >> > >> On 20 July 2013 10:47, Mikera <mike.r.an...@gmail.com <javascript:>> > wrote: > >>> Do you mean something like (int-array [1 2 3 4])? > >>> > >>> This is a cast-like operation that produces a primitive array of ints, > >>> exactly like int[] in Java. You can then use it with array operations > like > >>> "aget". > >>> > >>> If you want to type-hint int-array parameters then you need to use > something > >>> like "^ints", e.g. > >>> > >>> (defn third-int-in-array [^ints xs] > >>> (aget xs 2)) > >>> > >>> On Saturday, 20 July 2013 02:28:15 UTC+1, Brian Craft wrote: > >>>> > >>>> I'm unable to find any examples of primitive array casts, and the > docs are > >>>> not helpful. Can someone point me to examples or docs that explain > what they > >>>> do? > >>> > >>> -- > >>> -- > >>> You received this message because you are subscribed to the Google > >>> Groups "Clojure" group. > >>> To post to this group, send email to clo...@googlegroups.com<javascript:> > >>> Note that posts from new members are moderated - please be patient > with your > >>> first post. > >>> To unsubscribe from this group, send email to > >>> clojure+u...@googlegroups.com <javascript:> > >>> 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+u...@googlegroups.com <javascript:>. > >>> 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.