Hi,

even though I've using byte arrays many times, I'm still massively
confused each time I use them...

For example, why does this fail?

(byte-array [1 2 3 4])
ClassCastException java.lang.Long cannot be cast to java.lang.Byte
clojure.lang.Numbers.byte_array (Numbers.java:1223)

I understand ints are longs by default, but all of the values are in
byte-range and should not cause a casting error. Also creating an
int-array with the same values works just fine (and casts values
correctly):

(int-array [1 2 3 4])

Casting each value specifically to byte first works on the other hand:
(byte-array (map byte [1 2 3]))

Is that a bug or can someone please explain why bytes seem to require
special treatment in Clojure?

Thanks! K.
--
Karsten Schmidt
http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk

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


Reply via email to