> >> > look at lines 99 through 142 of "ersatz/fun.src" (actual version),
> >> > you see a lot of tedious type ('instanceof') checks. And they don't
> >> > even cover all possible cases! The same would be required for the
> >> > opposite direction. Or does anybody know a better way?
> > I say that the above code is a mess because it still has to check for
> > each possible type and take the appropriate action. As you can see, it
> > covers bytes, characters, integers, longs, doubles, bigIntegers,
> > strings, objects, byte arrays, char arrays, int arrays, long arrays and
> > double arrays. Other types, like short integers, or string arrays etc.
> > are not covered (and I hope they are not such important). BTW, I just
> > notice that booleans (and boolean arrays) are also missig; booleans
> > might be needed.
> > I cannot see a generic way to do that.
> I haven't looked at your code, but you might have a look at wl
> interpreter we discussed some time ago. The java ffi was quite complete
Yes, thank you!
However, I see that in the function 'jarg' you are doing the same (check
for all kinds of types).
I cannot see, though, whether you also handle a mapping of Lisp lists
from/to Java arrays, which doubles the code in the case of ErsatzLisp.
> and quite generic and more importantly, completely automatic, althought
> not the fastest due to relying on reflection completely. There is code
> for finding the right method and constructor with matching prototypes
In that sense, the same happens in ErsatzLisp.
It is just that I've put much more stress on execution speed, as I
possibly want to use ErsatzLisp in real applications (e.g. Android apps)
if I find the time.
BTW, how can I access existing objects (like "java.lang.System.err") in
wl? I can only find 'jnew', which creates new objects.