W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013


From: David Bruant <bruant.d@gmail.com>
Date: Mon, 02 Sep 2013 19:56:31 +0200
Message-ID: <5224D14F.3090002@gmail.com>
To: "public-script-coord@w3.org" <public-script-coord@w3.org>

I apologize in advance if this has been discussed already, I'm a bit 
behind regarding promise discussions.

As far as I know, currently, standard functions that expect an object of 
a given type will throw when passed a promise. However, wouldn't it be 
elegant to do:

     var dataP = getData(url1); // http GET
     var templateP = getTemplate(url2); // http GET
     var nodeP = Promise.every(templateP, dataP).then(compileTemplate);

What this would take is to add a preambule to every WebIDL operations, 
something like:
     If at least one of the argument is a promise, then, execute the 
         var argsP = Promise.every(...args);
         return argsP.then(operation);
(so, the document.body.appendChild call above actually returns an unused 

I sort-of like how generic this idea is. But, I have to ask:
1) how much of the web would this break?
2) how awful will performance of DOM/browser methods become? (more 
precisely, do implementors feel this is something they'll be able to 
optimize for easily?)
3) Does it make sense to apply the same thing for ECMAScript functions? 
I feel it could make sense for Date.setMonth, but maybe not for 

Nothing comes to mind for 1). And I'll let the relevant people answer 2) 
as I don't feel qualified. I'm not entirely clear for 3)

Received on Monday, 2 September 2013 17:57:00 UTC

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