
[Christian Tismer]
... Yup. With a little counting, it was easy to survive:
def main(): global a a=2 thing (5) a=a-1 if a: saved.throw (0)
[Tim]
Did "a" really need to be global here? I hope you see the same behavior without the "global a"; [which he does, but for mysterious reasons]
[Christian]
Actually, the frame-copying was not enough to make this all behave correctly. Since I didn't change the interpreter, the ceval.c incarnations still had copies to the old frames. The only effect which I achieved with frame copying was that the refcounts were increased correctly.
All right! Now you're closer to the real solution <wink>; i.e., copying wasn't really needed here, but keeping stuff alive was. In Scheme terms, when we entered main originally a set of bindings was created for its locals, and it is that very same set of bindings to which the continuation returns. So the continuation *should* reuse them -- making a copy of the locals is semantically hosed. This is clearer in Scheme because its "stack" holds *only* control-flow info (bindings follow a chain of static links, independent of the current "call stack"), so there's no temptation to run off copying bindings too. elegant-and-baffling-for-the-price-of-one<wink>-ly y'rs - tim