Sylvain Wallez wrote:

Vadim Gritsenko wrote:

Hi all,

I think I'm missing something... But according to my observations, continuations are not capturing current state of the local variables. Consider following snippet:

...

What I suggested some time ago about this is to have some kind of ContinuationLocal variables, similar to what ThreadLocal are to threads. The idea is that an object shared by a number of continuation holds a value, but this value is different for each continuation.

This could be implemented by associating a Map to continuations. To be truly useful, however, setting the value of a ContinuationLocal must associate that value with the _next_ continuation that will be created.


I'm feeling that you want to do this in Java code, hence it will not work with Rhino Continuations themselves (which are first-class Rhino objects), so it will be more like a hack around an issue, isn't it?

Ok... I think I've got an idea... Christopher, is it possible to access continuation which is being captured (or being restored) from within the catch(break|continue)? This will somewhat resolve the issue with capturing local variables:
catch (break) {
continuationWhichIsBeingCaptured.myCapturedVariable = i;
}
catch (continue) {
i = continuationWhichIsBeingCaptured.myCapturedVariable;
}


But this is still kind of hacky. I'd prefer something cleaner.

Vadim

Reply via email to