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