Toby wrote:
Leszek wrote:
Simply speaking: page local is a special variable that has different
values in different continuations.
So it seems that a continuation by default only saves the "program
counter" (or equivalent notion in JS) but not the local variables.
This is a bit counter-intuitive, and blatantly against the
documentation[1], but you clearly explained the reasons behind it.
What about global variables?
And the parameters of a (recursive) function call?
I have run a little test and frankly I don't understand what's
happening any more.
var called = 0
function f(x) {
called++
cocoon.sendPageAndWait('test', { x: x, called: called })
f(x + 1)
}
function called_from_sitemap() {
f(1)
}
called is a global variable. There is a sitemap matcher that calls
called_from_sitemap(), which in turn calls f(1), which calls f(2), etc.
Every new call to f() increments called (which should grow on par with
the stack of x parameters) and sends both variables to 'test', which is:
<html>
<body>
<p> x = ${x} </p>
<p> called ${called} times </p>
<p> <a href="cont=${continuation.id}">next</a> </p>
</body>
</html>
The cont=* pipeline calls the continuation.
Following the 'next' links, I expected to see:
x = 1, called 1 times
x = 2, called 2 times
x = 3, called 3 times
At which point I would start playing with the continuations, going back
and forth. Instead I get:
x = 1, called 1 times
x = 1, called 1 times
x = 1, called 1 times
What's happening?
This may have something to do with tail-call elimination.
http://wiki.apache.org/cocoon/RhinoWithContinuations
It probably should also get it's place in official documentation.
--
Leszek Gawron [EMAIL PROTECTED]
IT Manager MobileBox sp. z o.o.
+48 (61) 855 06 67 http://www.mobilebox.pl
mobile: +48 (501) 720 812 fax: +48 (61) 853 29 65
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]