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


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