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: "kawa at sourceware dot org list" <kawa at sourceware dot org>
- Cc: Jamison Hope <jrh at theptrgroup dot com>, Morven Sun <sunixm at gmail dot com>
- Date: Sun, 09 Jun 2013 13:03:23 -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>
On 06/09/2013 12:31 AM, Jamison Hope wrote:
There seems to be a bug, though: (apply + (object[] 1 2 3))
should work, but instead throws an error about trying to cast 1
to a procedure. I think the problem is the bit in
Apply#getArguments() where it says
if (count == 2)
return last_arr;
It seems like that should be "if (count == 1)", since it otherwise
is completely dropping the first argument to apply (i.e. the actual
procedure).
Good catch. Thanks.
Primitive arrays are not supported at all, though, since they are
disjoint from Object[]. I'm sure a patch would be welcome to allow
for them, but it'll be a hassle since you have to handle each
primitive type separately (and there are 8 of them).
Luckily, we can delegate this hassle to java.lang.reflect.Array.
I just checked in a patch (along with some tests) to do that.
On 06/09/2013 01:49 AM, Morven Sun wrote:
If all these arrays works the same way, the program would be much
easier to write. :)
I've seen this in Mathmatica, It's like Scheme but much more consistent.
It's partly a question of priorities and lack of time, partly having
to live with various constraints, including past practice,
Yes, some runtime penalty would be suffered. But it's not the
performance that all matters, isn't?
Runtime performance isn't all that matters, but it's pretty important.
It's one of the selling points of Kawa:
http://per.bothner.com/blog/2010/Kawa-in-shootout/
--
--Per Bothner
per@bothner.com http://per.bothner.com/