Claus Reinke claus.reinke at
Tue Nov 6 15:42:06 PST 2012

> I agree that promises should be standardized in Ecma-262. 

Agreed. That would also offer the possibility to support promises
in syntax. In ES7 (latest), I would like to see something roughly like

    { ...;
      let x <- promise;

(read as "let x from promise"), desugaring into

    { ...;
      promise.then( (x) => { ...; };

Essentially, this is an even shallower continuation than generators
(only the remaining statements in the current statement list), but it
is already sufficient to avoid callback nesting issues in async code. 
It also suffices to implement generators, but for syntax. 

By relying on nothing but a '.then' method, this isn't tied to promises
in the narrow sense, but provides a reusable building block for other 
control abstractions (to begin with, abstracting away the default
error handling in some APIs).


More information about the es-discuss mailing list