Suppose, I have the following code (in C-like syntax):
void foo(int arg) { ... } int bar() { ... // call with continuation ... } foo ( bar() ) // after foo invocation
1) Function foo
invokes function bar
, which is running until it reaches the line with call with continuation
.
2) At this line a continuation
function is created. It represents the rest of bar
and foo
. The continuation
function is passed as an argument to call with continuation
function.
3) The call with continuation
function does whatever it wants with the argument (e.g. it may just store in a global variable) and returns.
4) Once the call with continuation
returns we immediately jump to the line with "after foo invocation" and the rest of bar
and foo
are not executed.
5) In order to continue execution of bar
and foo
we should explicitly invoke the continuation
function (created in (2) and probably stored in (3)). Once the continuation
function is invoked the execution continues immediately after the call with continuation
.
Is it correct? Am I missing something about undelimited continuations?