A very interesting read indeed Alexander! Gave me a new example to give when
people ask what the worst code I'd ever seen was:
Promise<void> DoSomething(Promise<string> cmd) { return cmd.WhenResolved( s =>
{ if (s == "...") { return DoSomethingElse(...).WhenResolved( v => { return
...; }, e => { Log(e); throw e; } ); } else { return ...; } }, e => { Log(e);
throw e; } ); }
My question is however, that this article defines that an `await` keyword must
be within an `async` function, which seems an interesting choice to me. For
example, the following code snippet:
function callee() { let x = await someAsync(); }
Should `callee()` be asynchronous here? To my mind, no, it shouldn't. Every
single line here is synchronous, so the function itself should surely be
synchronous. Shouldn't functions that may not have `await` in them, but
instead that are actually asynchronous and hence use the `async return` keyword
be the ones we define with `async`?
Although, saying that, I think I may steal their use of `async Bar()` when
calling functions and add it to the proposal. It makes sense to me that `let x
= someAsync()` should error out to let developers know they're doing something
wrong. `let x = async someAsync()` clearly does show that they know the
function is async and will return a promise..
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss