Re: Why a Long class instead of integer class

2014-08-05 Thread Cecil Westerhof
2014-08-06 1:59 GMT+02:00 Alex Miller : > And in general it really is Long (not long) - by default all Clojure > values are objects, unless you have taken steps to use primitives. > ​You are right: (class 0) gives: java.lang.Long​ > > > On Tuesday, August 5, 2014 10:47:57 AM UTC-5, Mich

Re: Why a Long class instead of integer class

2014-08-05 Thread Alex Miller
I don't know that I agree with that reason. Clojure numerics start from an assumption of a 64-bit world, so numbers default to 64-bit types: long and double, instead of 32-bit int and float. Java interop is one of the places where this default can create a mismatch, since Java tends to use 32-bi

Re: Why a Long class instead of integer class

2014-08-05 Thread Michael Klishin
On 5 August 2014 at 19:43:21, Cecil Westerhof (cldwester...@gmail.com) wrote: > > Because of the class of those values is Long. Why are those not > Integer? To avoid the performance penalty of automatic promotion. In dynamically typed languages with auto-promotion of integers you have to perfor

Why a Long class instead of integer class

2014-08-05 Thread Cecil Westerhof
I have the following code: (def intArr (make-array Integer 10)) (for [i (range 10)] (aset intArr i (int 0))) (for [i (range 1)] (let [index (rand-int 10)] (aset intArr index (int (inc (aget intArr index)) (for [i (range 10)] (println (aget intArr i))) I need to use (int 0)