This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why (apply + (int[] 1 2 3)) won't work ?


On 06/10/2013 07:34 AM, Jamison Hope wrote:
That works, as long as it's deemed acceptable for the object
representations to be the standard Java number classes and not the
gnu.math types.  I suppose that already ought to be the case any
time that we'd be passing a primitive array to apply and expecting
it to do the right thing.

In the past Kawa only supported arithmetic on gnu.math classes,
and primitive numbers by default were boxed as gnu.math.*
instances (e.g. gnu.math.IntNum).  Later Kawa was enhanced
to support arithmetic on the standard boxes types (e.g.
java.lang.Integer), and the default primitive->object boxing
conversion was changed to use those, for better compatibility
with Java.

Thus:

(let ((ii (int[] 4 5 6)))
  (invoke (car (list (ii 1))) 'getClass))
  ==> class java.lang.Integer

(let ((i ::int 123))
  (invoke (car (list i)) 'getClass))
  ==> class java.lang.Integer

(let ((i  123))
  (invoke (car (list i)) 'getClass))
  ==> class gnu.math.IntNum

--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]