Thank you, works like a charm and makes my code smell better. On Tuesday, July 2, 2013 8:48:14 PM UTC+4, Christophe Grand wrote: > > => (def a (object-array 1)) > #'user/a > => (set! *warn-on-reflection* true) > true > => (aset a 0 nil) > Reflection warning, NO_SOURCE_PATH:1:1 - call to aset can't be resolved. > nil > => (aset ^objects a 0 nil) > nil > > > hth, > > Christophe > > > On Tue, Jul 2, 2013 at 5:13 PM, Mikera <mike.r.an...@gmail.com<javascript:> > > wrote: > >> 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/** >>> 70b376f58ec3846df6622b971001c3**ade32d0725/src/main/clojure/** >>> clojure/core/matrix/impl/**ndarray.clj#L30<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/** >>> 70b376f58ec3846df6622b971001c3**ade32d0725/src/main/clojure/** >>> clojure/core/matrix/impl/**ndarray.clj#L259<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 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. >> >> >> > > > > -- > On Clojure http://clj-me.cgrand.net/ > Clojure Programming http://clojurebook.com > Training, Consulting & Contracting http://lambdanext.eu/ >
-- -- 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.