Leopold Toetsch <[EMAIL PROTECTED]> writes: > Piers Cawley <[EMAIL PROTECTED]> wrote: >> So, I'm trying to get my head 'round parrot's continuations. It's my >> understanding that, at creation time, a Continuation closes over the >> current user stacks, control stack and lexical pad (and possibly some >> other stuff but those'll do for now). > > Yes register stacks. Which is one problem of your code. The calling > sequence has a "savetop" inside, which isn't in the Continuations > context.
But why do I need the savetop? I only care about the > > I already posted an working example. > Here is another one (comments indicate problems with your code: > > .sub main > $P0 = new PerlUndef > $P0 = "Howdy, world\n" > save $P0 > # create continuation inside, so that it has this in context > savetop > $P1 = newcont after > P5 = $P1 > P0 = find_global "_invoker" > invokecc > after: > restoretop > restore $P2 > print $P2 > > end > # end *is* needed in main > .end > > .sub _invoker > # ^^ global labels have an underscore > .param pmc a_cont > invoke a_cont > .end > >> Weird hunh? > > As long as no one really can tell the semantics of Continuations, they > have to be hand-crafted like above. So why does the generated pasm work where the PIR doesn't? I can see why saving P0-2 would be a good idea, but after doesn't need any of the other registers.