From: Leopold Toetsch <[EMAIL PROTECTED]>
   Date: Thu, 5 Jan 2006 11:38:04 +0100

   On Jan 5, 2006, at 3:26, Bob Rogers wrote:

   >    2.  Even without an error, it seems that actions could sometimes be
   > run twice because stack_pop compared entry->cleanup to 0 instead of
   > STACK_CLEANUP_NULL.  (I can't reproduce this now, so it probably
   > depended on something else as well.)

   Well, STACK_CLEANUP_NULL is ((Stack_cleanup_method)NULLfunc), which is 
   the same as 0 on all current platforms (AFAIK), but your patch is of 
   course correct.

Then this doesn't explain how I fixed the double invocation problem.  It
could be that the problem itself was just a figment of my imagination,
an artifact of hastily rewriting the test case (my vote), or something I
had introduced temporarily while reordering find_exception_handler code.
Oh, well.

   >    3.  Actions are not run at all if the context is skipped by calling 
   > a
   > continuation.  This is a deeper problem, so I've just added a TODO test
   > in order to document it as a known problem; I hope to fix this in the
   > course of implementing dynamic binding.

   It should work, when implementing the stack unwinding in 
   Continuation.invoke (which is also called by Exception_handler.invoke). 
   Now the question arises: what to do on the 2nd time the sub is running. 
   There are probably 2 options:
   a) user code has to reenable exception handlers and cleanup actions, 
   i.e. above stack unwinding is permanent
   b) the control stack remains unchanged, all exception handlers and 
   cleanup actions are still in place.

If I had to choose between these two, I'd say that 'b' is easier,
because popping is easier than repushing.

   But it would be much nicer if the dynamic state were automagically
restored to the same exact state as when the closure was taken; then, no
adjustments are necessary in PIR code.  This can be done if the
continuation stores some notion of the binding_stack state at that time.
I am expecting to argue (when I have time to complete the research) that
dynamic bindings should also be kept on the control stack; if that
happens, then the rezipping process can also do the right thing wrt
restoring exception and action state, almost for free.

   That's why I didn't want to try to fix the continuation-unwinding
issue now; I am hoping to get multiple birds with a single stone.

   How convenient for all this that Exception_handler is a subclass of
Continuation.  It's always good to Do The Right Thing, but much easier
if you can simply inherit it.

                                        -- Bob

Reply via email to