From: Stone Zhong on
Writing async code is complicated, you need to main status. If you are
in a call-stack (there are many functions above you in the stack), and
you are calling a function foo, foo returns, but the task foo is
suppose to complete is not yet completed, wouldn't it be nice, if the
language has a feature to save the call stack, and when foo can
restart the task, it will resume from the stack, so all the function
in the stack above still have the local variable in place.

Of course this does not apply in all cases, for example if you do want
multiple async task happen concurrently, but in case if all async task
are serialized in the main function, such strategy can simplify your
code a lot.

- Stone
From: Ry Nohryb on
On Aug 10, 7:28 am, Stone Zhong <stone.zh...(a)gmail.com> wrote:
>
> Writing async code is complicated, you need to main status. If you are
> in a call-stack (there are many functions above you in the stack), and
> you are calling a function foo, foo returns, but the task foo is
> suppose to complete is not yet completed, wouldn't it be nice, if the
> language has a feature to save the call stack, and when foo can
> restart the task, it will resume from the stack, so all the function
> in the stack above still have the local variable in place.
>
> Of course this does not apply in all cases, for example if you do want
> multiple async task happen concurrently, but in case if all async task
> are serialized in the main function, such strategy can simplify your
> code a lot.

Do you mean continuations http://en.wikipedia.org/wiki/Continuation ?

I think they (the ECMA committee) once wanted to put that into ES4,
but, IIRC they ended up discarding them for some reason. I think
Brendan Eich touched this matter in
http://developer.yahoo.com/yui/theater/video.php?v=eich-yuiconf2009-harmony

--
Jorge.
From: Stone Zhong on
On Aug 10, 12:31 am, Ry Nohryb <jo...(a)jorgechamorro.com> wrote:
> On Aug 10, 7:28 am, Stone Zhong <stone.zh...(a)gmail.com> wrote:
>
>
>
> > Writing async code is complicated, you need to main status. If you are
> > in a call-stack (there are many functions above you in the stack), and
> > you are calling a function foo, foo returns, but the task foo is
> > suppose to complete is not yet completed, wouldn't it be nice, if the
> > language has a feature to save the call stack, and when foo can
> > restart the task, it will resume from the stack, so all the function
> > in the stack above still have the local variable in place.
>
> > Of course this does not apply in all cases, for example if you do want
> > multiple async task happen concurrently, but in case if all async task
> > are serialized in the main function, such strategy can simplify your
> > code a lot.
>
> Do you mean continuationshttp://en.wikipedia.org/wiki/Continuation?
>
> I think they (the ECMA committee) once wanted to put that into ES4,
> but, IIRC they ended up discarding them for some reason. I think
> Brendan Eich touched this matter inhttp://developer.yahoo.com/yui/theater/video.php?v=eich-yuiconf2009-h...
>
> --
> Jorge.

Thanks Jorge, now I know what I mean is called "Continuation" -- it is
a good learning experience and thanks!