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

Re: Promises: Auto-assimilating thenables returned by .then() callbacks: yay/nay?

From: Mark S. Miller <erights@google.com>
Date: Tue, 7 May 2013 17:08:52 -0700
Message-ID: <CABHxS9hCUOxqy_2eajnad3jcdO4yS3EthUd3bZqErcGwyBbXrQ@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: David Sheets <kosmo.zb@gmail.com>, Sam Tobin-Hochstadt <samth@ccs.neu.edu>, "Tab Atkins, Jr." <jackalmage@gmail.com>, Domenic Denicola <domenic@domenicdenicola.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Tue, May 7, 2013 at 4:38 PM, Jonas Sicking <jonas@sicking.cc> wrote:

> On Tue, May 7, 2013 at 3:16 PM, David Sheets <kosmo.zb@gmail.com> wrote:
> > Could you please explain which part of the promise concept makes this
> > eager evaluation necessary?
>
> The promise concept doesn't. But I've not seen any libraries that
> permit it. I.e. I haven't seen any libraries that allow the creator of
> the promise to be notified when someone registers to be notified about
> the value.
>

Hi Jonas, although I agree with your overall point, Q.makeRemote as defined
at <
https://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/ses/makeQ.js#458>
does enable the creator of a remote promise to detect when it has been
.then-ed. This is sufficient to express promises that lazily evaluate,
although not conveniently and not the purpose of the API.



>
> >> So they do not provide the ability to postpone a calculation until
> >> someone that has access to the promise requests the calculation to be
> >> performed.
> >
> > I have a promise library on my disk that does provide this ability. It
> > is a trivial extension.
>
> The question isn't what can be implemented. The question is what
> existing libraries and code does as that is an indication of what
> people have requested.


Agreed. Q.makeRemote exists so that the distributed systems code stretching
Q between machines can be written in JS as a client of Q without surprising
or unnecessary special privilege.


-- 
    Cheers,
    --MarkM
Received on Wednesday, 8 May 2013 00:09:19 UTC

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