> I hope this explains it a bit for you.

Sorry, but it didn't explain much. What to you mean by "that'd break when
using multiple returns with different types" ? Can you throw some simple
example?


sure

var k = new Promise((acc, rej) => window.setTimeout(1000, ()=>
acc(randomPromiseSubtype)));

~=

var k = (async function() {await window.setTimeout(1000); return
randomPromiseSubtype})();

type of var k cannot be determined when the promise is made, due to the
timeout not yet having returned. Ahead-of-time determining of type is
really impossible with unpure functions, which must be available in async
functions (e.g. for fetch). You can wrap your async function call in a
custom promise (which would have your desired result), changing promise
instance class hierarchies on-the-fly would make promises much less
deterministic than what they are now, and would​ introduce confusion:
typeof k would change depending on how long your program has run.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to