Re: Loop handle

2010-04-10 Thread John Rose
On Apr 10, 2010, at 3:01 PM, James Thorpe wrote: > If CPS is out - what about passing the loop condition and body into a > function that does the looping for you. http://blogs.sun.com/jrose/resource/jsr292/LoopHandle.zip -- John ___ mlvm-dev mailing

Re: Loop handle

2010-04-10 Thread James Thorpe
If CPS is out - what about passing the loop condition and body into a function that does the looping for you. in pseudo code defn loop_fn(cond, body) while (cond()) do body() end end this avoids the need for tail calls entirely - and I presume the whole lot

Re: Loop handle

2010-04-10 Thread Charles Oliver Nutter
With tail calling, it would certainly be possible. I think the tradeoff would be accepting that you wouldn't be able to completely compose a body of code in one shot; somewhere downstream you'd have to defer a decision like whether to exit the loop or not. That would probably mean slicing the nativ

Loop handle

2010-04-10 Thread James Thorpe
This idea is a real gem! Would it not be possible to remove the need for a looping handle by a CPS conversion? James. On 10/04/2010, at 5:00 AM, [email protected] wrote: > > I ask because I still have a perverse desire to follow up on an idea > John Rose gave me to implement

Re: Loop handle?

2010-04-09 Thread Charles Oliver Nutter
nto handles something like this: GuardWithTest ..InvokeDynamic "foo" # condition VariableLookup "a" ..InvokeDynamic "+" # then VariableLookup "b" VariableLookup "c" ..InvokeDynamic "bar # else And because direct method handles get composed toge

Re: Loop handle?

2010-04-09 Thread Fredrik Öhrström
Charles Oliver Nutter wrote: > I ask because I still have a perverse desire to follow up on an idea > John Rose gave me to implement JRuby's interpreter entirely with > MethodHandles...with the obvious result being that by simply composing > a set of handles they'll already be compiled to native co

Re: Loop handle?

2010-04-09 Thread Charles Oliver Nutter
Yes, that thought crossed my mind. If tail calling were there, the only missing piece would be allowing a downstream handle (toward the target) to be able to be rebound to an upstream handle. Currently handles are a one-way street. On Fri, Apr 9, 2010 at 2:20 AM, Emmanuel Castro wrote: > Maybe th

Re: Loop handle?

2010-04-09 Thread Emmanuel Castro
Maybe there is no need to have a special handle for loops if there is an (hidden?) support for tail call in method handles ;-) I remind me a blog page from John Rose: http://blogs.sun.com/jrose/entry/tailcalls_meet_invokedynamic There is questioning about putting coroutine in Java7. Will Java7 inc

Loop handle?

2010-04-08 Thread Charles Oliver Nutter
It occurred to me today I may have never asked about this, but why is there no looping handle? (or have I missed something?) loopHandle(MethodHandle condition, MethodHandle body) In the current set of handles, I don't believe there's a way to construct a loop, since you can only link handles upwa