Do futures represent a pipeline? (was Re: Future cancellation)

Tab Atkins Jr. jackalmage at gmail.com
Wed May 1 09:13:20 PDT 2013


On Tue, Apr 30, 2013 at 12:49 PM, Kevin Gadd <kevin.gadd at gmail.com> wrote:
> Thanks, the idea that .then() returns a new Promise is very very strange to
> me. What gets stored into that promise?

Yes, promises can be through of as pipelines.  The return value of
.then() is a *new promise*, which gains its value from the .then()
callbacks - if the callbacks return a value, it accepts/resolves with
the same value; if they throw, it rejects with the error.

The reasoning behind promises/futures is explained in more detail in
my blog posts <http://www.xanthir.com/b4PY0>
<http://www.xanthir.com/b4P_0> and Domenic's
<http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/>.

> I think I see a lot of the historical confusion here as being rooted in the
> fact that the terms 'promise' and 'future' seem poorly-suited for describing
> a pipeline oriented primitive, if that's what these futures are. Maybe all
> discussion threads on futures need a big hairy disclaimer that tells people
> to read a description of what 'future' and 'promise' actually mean in this
> context :)

I think "future" is a pretty good name, personally - it means that the
callbacks will be run in the future. ^_^  But "promise" also kinda
works, and it's more common.  But DOMFuture definitely needs more
explanatory text (which I've promised to submit a pull request to
provide...).

~TJ


More information about the es-discuss mailing list