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?


Toby

[1] As I pointed out in a previous email, this page
http://cocoon.apache.org/2.1/userdocs/flow/continuations.html says:
«Think of a continuation as an object that, for a given point in your
program, contains a snapshot of the stack trace, including all the local
variables, and the program counter.»

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to