Rife continuations and recursion

View: New views
2 Messages — Rating Filter:   Alert me  

Rife continuations and recursion

by bonehead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys,
 
I have been playing around with the new fixes for Rife and recursion and am unable to get it working exactly as I would like. I am wondering if this is due to a incorrect notion on my part of how you have designed the continuations to work.
 
My first question is about the use of the continuation method taking parameters. The resume method being based on run also is required to keep the same signature and so requires that the original parameters are passed. How do these relate to the param values that were passed in when the first execute? Given that They were passed originally do the values used in the resume replace the original param values? If this is the case how doe this relate to a method that is recursive (as per my example) which is creating a call stack where the param values are altered as the recursion descends.Is it possible to build a resume that takes no parameters and allows the recursion on the stack to continue where it left off.
 
My second question is related to the Hanoi example I sent. Printing out the param values it appears that the tail recursion part of the algorithm does not continue correctly i.e. it only returns once. Is this a problem with the clone flag in the continuablerunner?
 
Hope to hear form you soon
 
Cheers and thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Rife continuations and recursion

by Geert Bevin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Frederick,

sorry again for the late response, with JavaOne and all the related  
preparations, I had not much time to look at posts that took up some  
of my brain power ;-)

> My first question is about the use of the continuation method taking  
> parameters. The resume method being based on run also is required to  
> keep the same signature and so requires that the original parameters  
> are passed. How do these relate to the param values that were passed  
> in when the first execute? Given that They were passed originally do  
> the values used in the resume replace the original param values? If  
> this is the case how doe this relate to a method that is recursive  
> (as per my example) which is creating a call stack where the param  
> values are altered as the recursion descends.Is it possible to build  
> a resume that takes no parameters and allows the recursion on the  
> stack to continue where it left off.

If you store them in local variables, you can use  
ContinuationContext.getActiveContext().getParentContext() to inspect  
the previous continuation contexts.

> My second question is related to the Hanoi example I sent. Printing  
> out the param values it appears that the tail recursion part of the  
> algorithm does not continue correctly i.e. it only returns once. Is  
> this a problem with the clone flag in the continuablerunner?

No, this is due to your testParamPause() method that just invokes the  
continuation objects twice. You might want to create your own running  
that continues resuming until the solution is found.

Hope this helps,

Geert

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price
 
 
 
Google
rifers.org web