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: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 2 May 2013 13:27:42 -0700
Message-ID: <CAAWBYDCmZ+1jMgY6rS1KVqUt+nF4HOzDjzr==S4=C1nuCMB2QQ@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
On Thu, May 2, 2013 at 12:55 PM, Domenic Denicola
<domenic@domenicdenicola.com> wrote:
> From: Tab Atkins Jr. [jackalmage@gmail.com]
>> While I clear that up (since the naming and the behavior are not inconsistent, which is extremely confusing),
> This isn't really true. The `acceptCallback` is the callback called when the promise is fulfilled ("accepted" in the DOMFuture promise library). It uses `resolve` semantics to process its return values, but it would need to do that anyway, in order to get different behavior for promises and for values. You need to distinguish between the condition on which the callback is called, and the behavior of the callback with respect to its return values.

Yes, the first callback to .then() needs to use resolve semantics, so
you can return either a plain value or a future.  Right now, though,
"resolve semantics" means "recursively flatten nested futures until
you end up with a single future holding a plain value".

I thought I'd gotten several people, including you and Mark Miller, to
acknowledge that recursive flattening was not necessary for native
promises, only non-native promise-likes ("thenables").  If necessary,
I can go dig up the exact email from you where you said that the
use-case for recursive flattening was assimilation, and it wasn't
necessary to automatically do so for native promises.

>> can you comment on the rest of my message?
> There's not much to say. I think assimilating thenables is good, for reasons that have been discussed at length before. You disagree. I have a hard time seeing what else you'd find helpful from me.

What I'm hoping for is an explanation of why assimilating thenables is
necessary in the .then() callbacks, and why my concerns about
predictability (such as returning an object which has a .then()
method, but is not a promise-like, which "assimilates" with
non-sensical behavior and possibly causes errors) are either unfounded
or less important than the benefits of auto-assimilation.

To be clear, I'm *completely for* assimilation, just via an explicit
function call.

Received on Thursday, 2 May 2013 20:28:29 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:13 UTC