Michal Wallace <[EMAIL PROTECTED]> wrote: > A .pcc_sub isn't an object, just a little segment of the list of > instructions.
A pcc_sub *is* an object: find_global P0, "_the_sub" invokecc print "back\n" end .pcc_sub _the_sub: print "in sub\n" invoke P1 You can store it away, pass it around and so on. > My problem is that I don't know what a Control stack, pad stack, > user stack, and warnings are. > Here's my guess: > ControlStack { > This is another set of smaller papers. One box each. > if Mr. Parrot meets a "ret" op, he takes the > top sheet and goes to whatever address is on it. Yes, its used for C-like function calls, where the return address is on the control stack. But more importantly: the control stack has exception handlers on it. If you install an exception handler, its pushed onto the control stack. If an exception is thrown, the handler is popped off that stack and control transfers to the handler subroutine. > When we call a Sub, we write the return address on > the top sheet. Same with a closure. No. Subs and Closures are invoked, no control stack is involved > ** I don't understand what happens here when we call > a continuation. Same here. > PadStack { > Hmm. Does this mean lexical pads? Yep. C< { my $i; } > would create/push a new lexical pad with that variable name inside. > UserStack { > By process of elimination, this would be the eight > register stacks? No. Its an intermediate store to save registers. Its used: a) for C-style function calls b) to get at return results, if the caller did save all 32 registers: pushp # save P0..P31 to register frame invoke # call a sub - result in P5 save P5 # save P5 onto user stack popp # restore P0-P31 from register frames restore P5 # pop off result from user stack > Warnings { > ** Beats me. Is this for holding exception handlers? This are the warning flags. When you call a sub and that turns off warnings, the warning flags are restored to the original state, when the sub returns. > Final questions: > What's a context? The context holds pointers to all these stacks and structures. The semantics of the different Sub types define, how to deal with items in the context. E.g. a Closure has the callers pad stack in its context, so that a Closure can access lexicals of the caller. > How would I picture Eval? Does that involve building new houses? A new street with new houses. > For a sub, he just writes a return address on the control stack No, not for Parrot Calling Conventions. A Sub is an object. Again: We have 2 calling conventions: 1) C-style 2) PCC Only 1) is using return addresses pushed onto the Control Stack. > The class tree in subs.pod is confusing to me: > Sub > Closure > Continuation > Coroutine > Eval > RetContinuation These are all for 2) - no pushed return address is involved. > Michal J Wallace leo