Enable async/await to work on functions that don't just return promises.
Michał Wadas
michalwadas at gmail.com
Mon Feb 27 22:24:24 UTC 2017
Actually, this proposal would be a revolution and I can think of too
many edge cases to make it viable.
Consider:
async function foo() {
async function bar() {
[1,2,3].forEach(async function() { async return
3; });
} return (await bar()) + 39;
}
What does happen here? For me it's absolutely counterintuitive.
What about functions coming from other scopes, like?
async function foo() {
function bar() {
[1,2,3].forEach(async function() { async return
3; });
} return (await bar()) + 39;
}
Or multiple returns?
async function foo() {
setTimeout(()=>{ async return 42; }, 0); return null;
}
Promisification should be done by userland libraries, not by introducing
new syntax.
On 27/02/17 22:17, Isiah Meadows wrote:
> I was speaking objectively about the proposal itself, and the scope of
> it. I'm personally strongly against it for reasons I stated earlier in
> the thread (the status quo is better IMHO). I was just trying to
> direct people back to the actual scope of the proposal instead of
> basically reinventing async functions using async functions, and also
> simultaneously attempting to assist the OP in better understanding
> what he's really trying to propose (which he didn't appear to grasp
> well).
>
> On Mon, Feb 27, 2017, 14:01 Tab Atkins Jr. <jackalmage at gmail.com
> <mailto:jackalmage at gmail.com>> wrote:
>
> On Mon, Feb 27, 2017 at 12:41 AM, Isiah Meadows
> <isiahmeadows at gmail.com <mailto:isiahmeadows at gmail.com>> wrote:
> > May I add one more thing: the main topic this was about is adapting
> > non-standard async APIs (like Node's error-first callback idiom)
> to the land
> > of promises. Async functions and iterators are incredibly useful
> when you're
> > dealing with just promises, especially consuming them, but this
> is about
> > creating promise adapters, not consuming promises.
>
> You don't need to change the behavior of core syntax to make
> Node-style error-first callbacks work. That's easily done by
> libraries, which have existed in Node-land for quite a while, and can
> automatically convert functions that take Node-style callbacks into
> functions that return promises.
>
> ~TJ
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170227/eab7709f/attachment.html>
More information about the es-discuss
mailing list