It will be nice if javascript function can be interrupted andre-entered at latter time

S

Stone Zhong

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
 
R

Ry Nohryb

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
 
S

Stone Zhong

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...

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top