Dan Sugalski <[EMAIL PROTECTED]> wrote:

[ mmd functions ]

Another question:

,--[ pdd15 ]------------------------------------------------------
|        While vtable methods may take a continuation, those
|        continuations may not escape the vtable method's
|        execution. This is due to the way that vtable methods are
|        called by the interpreter--once a vtable method is exited
|        any continuation taken within it is no longer valid and
|        may not be used.
`-----------------------------------------------------------------

This seems to indicate that there is no rule that this isn't allowed
generally. You could therefore pass a local label address to
another subroutine, which creates a Continuation and invokes that, or
pass the Continuation to yet another sub, which the returns to the
first.

How should we prepare a proper context then, so that when taking the
continuation, everything is restored? Its of course possible to achieve
that in PASM somehow but you can't do that with PIR.

I think, we need some higher-level constructs to deal with
Continuations (s. also a recent discussion with Piers).

Creating a continuation PMC is effectively the same as the call half of
a function call, w/o the call itself. The destination label of a
continuation is the other half of the function call, again w/o the call
itself.

E.g.

    set P17, P1               # preserve retc & self
    set P18, P2

    pushtopp                  # setup context
    cont = newcont cont_label
    popttopp                  # restore contex
    ...
    # return or branch

and:

 cont_label:
    poptopp
    set P1, P17
    set P2, P18

But his scheme can only work, when the continuation label is in the same
sub or method as the creation of the continuation.

leo

Reply via email to