Mark S. Miller (2013-08-01T18:04:00.000Z)
domenic at domenicdenicola.com (2013-08-05T20:08:46.243Z)
Between Tab's answer and mine, we see the two issues one might mean by "branding". Anne's clarifying summary at https://mail.mozilla.org/pipermail/es-discuss/2013-August/032465.html speaks only in terms of "promise-likes". One of the things we need to settle is whether there is one predicate that applies to all the places in this summary that says "if ... promise-like". IMO we need to distinct tests -- * isPromise for whether p is a promise and * isThenable for whether p is thenable. I would have the output-side tests for both .flatMap and .then be isPromise. I would also have the input side test for .then use isThenable. .flatMap has no input-side test, which is its point. A somewhat separable question is what these two tests are testing. The first hard reason why we must at least have an isPromise test on the output side of .then is that the promise already returned by .then must adopt this output promise without calling its .then method. Otherwise we lose support for lazy evaluation and for promise pipelining. If the output side of .then is a non-promise thenable, it is a separate question whether it should be "adopted" by calling its .then method or whether it should be accepted. IMO it should be accepted. The isThenable test indicates something ugly is going on -- assimilation. With this AP2 based design, we can isolate this ugliness to the input side of .then. The second reason why the two tests need to be separate is that the output side of .flatMap cannot adopt simply by calling the output's .then method, because otherwise you'd often get exactly the recursive unwrapping that .flatMap is trying to avoid. In order to avoid this, it must test whether there is anything it can do to adopt other than calling .then.