W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: Futures

From: Kevin Smith <zenparsing@gmail.com>
Date: Fri, 26 Apr 2013 14:03:39 -0400
Message-ID: <CA+mDt2yV6w-EBaykhP7paOzd9+Y0Wm+82FwyidG66txzSAN3Rw@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: David Sheets <kosmo.zb@gmail.com>, Brendan Eich <brendan@mozilla.com>, "Mark S. Miller" <erights@google.com>, Douglas Crockford <douglas@crockford.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>, Norbert Lindenberg <w3@norbertlindenberg.com>, Markus Lanthaler <markus.lanthaler@gmx.net>, EcmaScript <es-discuss@mozilla.org>
The current DOM spec, in code:

    Future.resolve(1).then(value => {

        value === 1;

        // Return a non-promise
        return 2;

    }).then(value => {

        value === 2;

        // Return a promise for a non-promise
        return Future.resolve(3);

    }).then(value => {

        value === 3;

        // Return a promise that *resolves* to a promise
        return Future.resolve(Future.resolve(4));

    }).then(value => {

        value === 4;

        // Return a promise *whose value* is a promise
        return Future.accept(Future.resolve(5));

    }).then(value => {

        value !== 5;

        // Return the value-which-is-a-promise
        return value;

    }).then(value => {

        value === 5;
    });

As a gist: https://gist.github.com/zenparsing/5469130

Please let me know if I made a mistake with the above.

{ Kevin }
Received on Friday, 26 April 2013 18:04:06 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:49 UTC