Is await really the right syntax?

Even with a higher precedence, await is a prefix operator and thus does not
chain well. Typical code is

    array.asyncMap(f1).asyncFilter(f2).asyncReduce(f3)

await forces you to write something like:

    await (await (await array.asyncMap(f1)).asyncFilter(f2)).asyncReduce(f3)

A postfix, or even better, infix, operator plays much nicer. For example,
the concurrency strawman ! proposal:

    array!asyncMap(f1)!asyncFilter(f2)!asyncReduce(f3)

I've been writing lots of code like this with streamline.js:

    array.asyncMap(_, f1).asyncFilter(_, f2).asyncReduce(_, f3)

A little more verbose and hackier than the ! operator but it chains well.
This makes a big difference in usability.

Bruno
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to