Hi Kevin, I misinterpreted you. By "earlier", I thought you were referring to the promise APIs in actual use which are compatible with Promises/A+. These do not create promises-for-promises (auto-flattening or auto-lifting depending on how you want to think about it) and they recursively unwrap thenables (assimilation). The first, auto-flattening/auto-lifting, is a requirement for the .then-oriented promise patterns in use, as has been discussed exhaustively here and on Promises/A+. The second, assimilation, is an unfortunate but expedient hack that enables multiple promise libraries to co-exist. The origin of the modern JS promises is the promise system of the E language which had auto-flattening/auto-lifting but no assimilation, since co-existence was not an issue.
The "earlier" you are talking about, IIUC, is the monadic promise variant. Monads are fine things, and a monadic promise=like abstraction would probably be useful for some things. However, it is a very different abstraction and it does not support the .then oriented patterns that JS promises are used with. I think we would be better off omitting these from standard promises, but we cannot get quick consensus on a promise system which omits them. Without a quick consensus, DOM will do something else. Fortunately, AP2 allows these to live together in one API more painlessly than I had thought possible. On Mon, Aug 19, 2013 at 7:17 PM, Kevin Smith <[email protected]> wrote: > Thanks Mark. > > To clarify my overly brief interjection, I tend to favor the conceptual > simplicity of the earlier "DOM" API. Specifically: > > - no "flatMap" > - the output of then is single-unwrapped > - no recursive unwrapping > > I find it more simple from a conceptual standpoint because each promise > simply resolves to some value (possibly a promise) which can be accessed > via then. > > If I remember correctly, AP2 was motivated by the need to support both > recursive unrwapping and single-unwrapping with a single API. It is a > clever solution, to be sure. But can we not simply provide a recursive > unwrapping helper function? > > Promise.when(unknown).then(unwrapped => console.log(unwrapped)); > > In this case, `unwrapped` will be the result of recursively unwrapping > `unknown`, if `unknown` is a promise, and the value `unknown` otherwise. > > { Kevin } > > > -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

