Christopher Oliver wrote:
Sylvain Wallez wrote:
Christopher Oliver wrote:
Sylvain Wallez wrote:
The call frames that represent the calls to f() and g() are shared between all continuations captured inside h(). But when a continuation escapes the while loop and returns to g(), then, at that point, a copy of the call frame of g() is made, and so on as you return up the stack.
Ah, I understand : common stack frames are shared between continuations having the same ancestor continuations.
Yes.
Also, how can local variables be shared between continuations if their value changes between calls to sendPageAndWait, as is the case of producList ? Isn't it contradictory with the continuation concept which should restore variable values ?
No. That's the intended behavior - just like in Scheme. Invoking a continuation only restores the program counter. It does not roll back changes to other data. That behavior would be way too expensive! As it is the cost of invoking a continuation is negligable.
Mmmmh... I guess what you mean here is that the PC and the stack frame are restored, which also includes local variables. What isn't restored is the state of objects pointed by these local variables.
Yes.
Does JavaScript, like Java, make a difference between primitive types (stored by value on the stack) and object types (stored by reference) ? My understanding after some tests is that a difference is made.
No, there shouldn't be any difference. If there is, it's a bug. What was your test?