Re: Continuations are broken?

2002-06-20 Thread Ovidiu Predescu

On 6/20/02 1:23 AM, "Sylvain Wallez" <[EMAIL PROTECTED]>
wrote:

> Vadim Gritsenko wrote:
> 
>> Can you explain (in two words ;) what is going on behind this, how
>> variable B in one continuation got value assigned to variable B in
>> another continuation? Do all continuations share same values?
> 
> Yes, please explain, Ovidiu, as the above breaks my understanding of
> continuation and their benefits...

Please see my response to Vadim about this.

Best regards,
-- 
Ovidiu Predescu <[EMAIL PROTECTED]>
http://www.geocities.com/SiliconValley/Monitor/7464/ (Apache, GNU, Emacs...)



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




Re: Continuations are broken?

2002-06-20 Thread Ovidiu Predescu

On 6/20/02 1:23 AM, "Sylvain Wallez" <[EMAIL PROTECTED]>
wrote:

> Vadim Gritsenko wrote:
> 
>> Can you explain (in two words ;) what is going on behind this, how
>> variable B in one continuation got value assigned to variable B in
>> another continuation? Do all continuations share same values?
> 
> Yes, please explain, Ovidiu, as the above breaks my understanding of
> continuation and their benefits...

Please see my response to Vadim about this.

Best regards,
-- 
Ovidiu Predescu <[EMAIL PROTECTED]>
http://www.geocities.com/SiliconValley/Monitor/7464/ (Apache, GNU, Emacs...)



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




Re: Continuations are broken?

2002-06-20 Thread Ovidiu Predescu

On 6/19/02 7:58 PM, "Vadim Gritsenko" <[EMAIL PROTECTED]> wrote:

>> Rhino used to have the behavior you described, but Christopher and I decided
>> is better to have the current one, which is more useful to real
>> applications.
> 
> You lost me! What has been changed? Or, better question, how it works
> now?
> 
> Can you explain (in two words ;) what is going on behind this, how
> variable B in one continuation got value assigned to variable B in
> another continuation? Do all continuations share same values?

When you invoke a function for the first time from the sitemap, a context is
created for it, which contains all the global variables, stack frames and
local variables.

As the program executes, all the created continuations will share this
context. This gives you not only the ability to modify script variables in
one place and inherit these values in subsequent pages, but it also allows
you to view the values of these modified variables in past pages, the ones
you visited before coming to the current one.

A common scenario for this behavior is a shopping cart, where you add items
in your cart in different pages. Imagine your cart is an array in your
script. If you go back in your browser's history and add a different item
starting an old page, you want that item to appear in your shopping cart
along with the others you already chose.

Since the context is shared among all the continuations, the only way to
have what-if scenarios is to start a new context, which is equivalent to
invoking a new top-level function. In the calculator sample, this is
equivalent to starting from scratch, e.g. from

http://localhost:8080/cocoon/samples/flow/examples/calc/

In the previous implementation of continuations in JavaScript, each
continuation had its own context for variables. Which meant that if you went
backwards in the pages history and restarted the computation, you would not
see the modifications made down the road, on another path. In the shopping
cart example, this was equivalent to having multiple instances of the
shopping cart, one for each page.

The new behavior is similar to how continuations are implemented in Scheme,
while the old one was a very early implementation of continuations in Rhino.
Thus Chris and I decided is better to stick with the accepted semantic of
continuations.

Does this help in understanding what's going on?

Regards,
-- 
Ovidiu Predescu <[EMAIL PROTECTED]>
http://www.geocities.com/SiliconValley/Monitor/7464/ (Apache, GNU, Emacs...)


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




RE: Continuations are broken?

2002-06-20 Thread Reinhard Poetz

> -Original Message-
> From: Ovidiu Predescu [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 20, 2002 4:48 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Continuations are broken?
>
>
> On 6/19/02 12:48 PM, "Vadim Gritsenko"
> <[EMAIL PROTECTED]> wrote:
>
> > Hi Ovidiu, and hi all,
> >
> > Either I did not understood continuations or they do not work as
> > advertised. Walk through this test case and tell what/who is wrong:
> >
> > 1) Access http://localhost:8080/cocoon/samples/flow/examples/calc/
> >
> > 2) Type "10", Enter.
> >
> > 3) See page with A = 10.
> > URL is
> > http://localhost:8080/cocoon/samples/flow/examples/calc/kont/3f557504821
> > 5621d3c1c32191d868b573f751c7f?a=10
> >
> > 4) Open another browser window with this URL. See page with A = 10
> >
> > 5) Window 1: Enter B = 10
> > URL will be:
> > http://localhost:8080/cocoon/samples/flow/examples/calc/kont/1b261330647
> > 176442d5f45335c406211594a1d4f?b=10&submit=Enter
> >
> > 6) Window 2: Enter B = 20
> > URL will be:
> > http://localhost:8080/cocoon/samples/flow/examples/calc/kont/6034270b2e1
> > a6b7c4a591512417a3c3c437c?b=20
> >
> > 7) Window 1: Select "plus", click "Do It"
> >
> > 8) See in Window 1: Result = 30.
> >
> > I expected to see 20, because B = 20 was entered in another window and
> > went to continuation 6034270b2e1a6b7c4a591512417a3c3c437c, and B =
> > 10 should be in continuation 1b261330647176442d5f45335c406211594a1d4f,
> > however, both continuations has same B = 20.
> >
> >
> > Am I mistaken?
>
> No, you're not mistaken, this is the correct behavior.
>
> Rhino used to have the behavior you described, but Christopher
> and I decided
> is better to have the current one, which is more useful to real
> applications.
>
> One effect of this change is that you can no longer implement what-if
> scenarios as easy as before. Christopher and I were talking about various
> solutions, but none of them is cheap enough at runtime to be worth the
> effort.

What is the advantage of continuations? It seems that the calculator example
has only one state ...

Regards,
Reinhard


>
> Regards,
> --
> Ovidiu Predescu <[EMAIL PROTECTED]>
> http://www.geocities.com/SiliconValley/Monitor/7464/ (Apache,
> GNU, Emacs...)
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>


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