This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: why (apply + (int[] 1 2 3)) won't work ?
- From: Per Bothner <per at bothner dot com>
- To: Jamison Hope <jrh at theptrgroup dot com>
- Cc: "kawa at sourceware dot org list" <kawa at sourceware dot org>
- Date: Mon, 10 Jun 2013 09:13:08 -0700
- Subject: Re: why (apply + (int[] 1 2 3)) won't work ?
- References: <CAKZUWfi_eL+x==736dpU6QdBLpHXHk8TaXYzWDmPheYXb0DzAw at mail dot gmail dot com> <51B42C0E dot 8080502 at bothner dot com> <90D06C3D-E227-4E22-9C8D-FEFA4612A9C9 at theptrgroup dot com> <51B4DF8B dot 70904 at bothner dot com> <68B3DF07-83C2-446F-9BD9-59A9F30D5729 at theptrgroup dot com>
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/