I think that is the only way. The good news is that this is Clojure, so you can easily wrap it in an "object-array-cast" macro....
On Tuesday, 2 July 2013 15:41:02 UTC+1, Dmitry Groshev wrote: > > Hello all. > > I have a following deftype: > > (deftype NDArray > [^objects data > ^long ndims > ^longs shape > ^longs strides]) > > ( > https://github.com/si14/matrix-api/blob/70b376f58ec3846df6622b971001c3ade32d0725/src/main/clojure/clojure/core/matrix/impl/ndarray.clj#L30 > ) > > Then, when I use "data" field in various contexts like aget/aset, Clojure > warns me about reflection (and rightfully so). It's not a problem with > primitive arrays because we can use (longs …) and similar functions to make > cast explicitly, but there is no (objects …). With some googling I've found > a following solution: > > (let [… > #^"[Ljava.lang.Object;" data (.data m) > …] > (aset data idx v)))) > > ( > https://github.com/si14/matrix-api/blob/70b376f58ec3846df6622b971001c3ade32d0725/src/main/clojure/clojure/core/matrix/impl/ndarray.clj#L259 > ) > > But it's really really ugly. Is there a way to make it better? > > -- -- 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.