Yes, that's an excellent point-- something like:

    function captured() {
        try {
            handler->();
            throw "throw";
        }
        finally {
            alert("finally!");
        }
    }

    function handler(k) {
        k();
    }

This calls the handler with A still on the stack, and the handler runs A again; 
then throwing passes through the finally twice, resulting in two alerts.

Thanks for the careful reading. Now I'm not sure whether the function call 
notation makes sense. There's a pigeonhole problem with finally: if you expect 
a capturing form of function call to happen in the context of its 
handlers/finalizers, but you also expect the handlers/finalizers to be executed 
when the activation is suspended, then you can't guarantee that a finally block 
only executes once.

With generators, this doesn't come up because `yield' simply jumps immediately 
out of the frame, without invoking additional user code first.

Dave

On Apr 12, 2010, at 7:08 PM, Waldemar Horwat wrote:

> David Herman wrote:
>>    Thinking about continuations
>>    http://calculist.blogspot.com/2010/04/thinking-about-continuations.html
> 
> Your attempted fix for evaluating finally blocks just moved the problem 
> elsewhere.  Since in the final expression you have A(... A(x)), you'll just 
> end up executing the same finally block twice under certain circumstances.
> 
>   Waldemar

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to