Re: MethodHandles for Kawa and other functional languages?

2010-10-11 Thread Helmut Eller
* Per Bothner [2010-10-10 23:38] writes: An example I was considering was: (define (twice f x) (f (f x))) My initial thought was to compile this as: public static Object (Procedure f, Object x) { MethodHandle f$mh = f.asMethodHandle(); return f$mh.invoke(f$mh.invoke(x)); }

Re: MethodHandles for Kawa and other functional languages?

2010-10-11 Thread Rémi Forax
Le 11/10/2010 02:21, Per Bothner a écrit : On 10/10/2010 02:20 PM, Rémi Forax wrote: guardWithTest is the missing piece. It should be something like that: ... Thanks! This is somewhat tricky - it will take a bit to grok it property. And I think I've forgotten to drop the first argument

Re: MethodHandles for Kawa and other functional languages?

2010-10-10 Thread Per Bothner
So we've determined that to make use of 292 Kawa should keep its abstract gnu.mapping.Procedure class, but add a new method: MethodHandle asMethodHandle() I mis-concluded that the compiler should therefore generate code to call asMethodHandle() and then the MethdHandle#invoke method. However,

Re: MethodHandles for Kawa and other functional languages?

2010-10-10 Thread Per Bothner
On 10/10/2010 02:20 PM, Rémi Forax wrote: Le 10/10/2010 20:08, Per Bothner a écrit : So we've determined that to make use of 292 Kawa should keep its abstract gnu.mapping.Procedure class, but add a new method: MethodHandle asMethodHandle() I mis-concluded that the compiler should

Re: MethodHandles for Kawa and other functional languages?

2010-10-10 Thread Per Bothner
On 10/10/2010 02:20 PM, Rémi Forax wrote: guardWithTest is the missing piece. It should be something like that: ... Thanks! This is somewhat tricky - it will take a bit to grok it property. Perhaps you need to add some conversions with convertArguments. But as I said, why do you want to

Re: MethodHandles for Kawa and other functional languages?

2010-09-30 Thread Alessio Stalla
On Thu, Sep 30, 2010 at 3:08 AM, John Rose john.r.r...@oracle.com wrote: On Sep 29, 2010, at 5:00 PM, Per Bothner wrote: Fundamentally, the question is: When the Scheme programmer passes of function to a higher-level function (like map), what is the type of the object passed: A MethodHandle?  

Re: MethodHandles for Kawa and other functional languages?

2010-09-30 Thread Alessio Stalla
On Thu, Sep 30, 2010 at 12:48 PM, Helmut Eller eller.hel...@gmail.com wrote: * Alessio Stalla [2010-09-30 07:44] writes: InvokeDynamic.#SOME-LISP-PACKAGE:FOO(...) and in the bootstrap method, roughly, ... Symbol sym = readFromString(methodName); MethodHandle mh =

Re: MethodHandles for Kawa and other functional languages?

2010-09-30 Thread Helmut Eller
* Alessio Stalla [2010-09-30 11:52] writes: On Thu, Sep 30, 2010 at 12:48 PM, Helmut Eller wrote: Just out of curiosity: what do you do if the package was renamed (say from SOME-LISP-PACKAGE to ANOTHER-LISP-PACKAGE) before the bootstrap method gets executed? It'll fail miserably :D I

Re: MethodHandles for Kawa and other functional languages?

2010-09-30 Thread Helmut Eller
* Alessio Stalla [2010-09-30 13:28] writes: I guess you could avoid reflection if you generate a custom bootstrap method for each callsite.  Hmm.. probably just as clumsy as reflection. Yeah, clumsy and suffering from code bloat - I'm already disturbed to have one static block registering

Re: MethodHandles for Kawa and other functional languages?

2010-09-30 Thread Alessio Stalla
On Thu, Sep 30, 2010 at 4:03 PM, Helmut Eller eller.hel...@gmail.com wrote: * Alessio Stalla [2010-09-30 13:28] writes: I guess you could avoid reflection if you generate a custom bootstrap method for each callsite.  Hmm.. probably just as clumsy as reflection. Yeah, clumsy and suffering

MethodHandles for Kawa and other functional languages?

2010-09-29 Thread Per Bothner
I'm interested into (at least) evaluating MethodHandles for Kawa (and similar languages with first-class functions). But I'm not quite sure where to start, or what is the right abstraction. Kawa's function implementation is fairly efficient. Calls to known functions compile to direct method

Re: MethodHandles for Kawa and other functional languages?

2010-09-29 Thread John Rose
On Sep 29, 2010, at 5:00 PM, Per Bothner wrote: Fundamentally, the question is: When the Scheme programmer passes of function to a higher-level function (like map), what is the type of the object passed: A MethodHandle? A Procedure? Something else? There seem to be different kind of