Single frame continuations proposal

David Herman dherman at mozilla.com
Wed Mar 31 09:56:52 PDT 2010


Hi Kris,

I've been poring over this for a while, and it's still really, really confusing. Could I ask you to show how you would write the following example with your proposal?

    function setup() {
        setFlashing(document.getElementById("notificationArea"));
        alert("done setup!");
    }

    var flashingElts = [];

    function setFlashing(elt) {
        var toggle = true;
        window.setTimeout(function() {
            elt.style.background = toggle ? "red" : "white";
            toggle = !toggle;
        }, INTERVAL);
        flashingElts.push(elt);
    }

And then would you mind showing a rough translation of your implementation to ES5 code (similar to the translation of your `foo' function)?

>>> 6. Resume *continuation*, using the value of *result* for the
>>> continued evaluation of the current expression (if the
>>> continuation is inside an expression).
>> 
>> Is this supposed to fall through?
>> 
> Yes

That can't be true, can it? If step 6 continues to step 7 then we get:

    // step 5
    if (!($result && typeof $result.continueWith === "function")) {
        // do step 6
    }
    // fall through
    var $waiting = true;
    var $continueWithResult = $result.continueWith($resume);

But we established in step 5 that there's no $result.continueWith function.

Dave



More information about the es-discuss mailing list