Piers Cawley <[EMAIL PROTECTED]> wrote:

Another f'up WRT Continuations. Here is an example how to setup a
Continuation:

# main.imc
.sub _main
     load_bytecode "set_a.imc"
     print "main\n"
     end
.end

# set_a.imc
.sub _set_a @LOAD
     .local pmc cont
     print "set_a\n"
     newsub .Sub, .RetContinuation, _sub, back
     savetop
     cont = newcont back
     P5 = cont
     invoke
back:
     restoretop
     print "back\n"
.end
.sub _sub
    .param pmc cont
     print "sub\n"
     cont()
.end

The Continuations is created inside the sub call sequence, so that it
has the saved registers in its context. Return through the continuation
or a normal return are equivalent then.

leo

Reply via email to