Precedence of yield operator

Bruno Jouhier bjouhier at gmail.com
Fri Jun 14 08:12:09 PDT 2013


While playing with my little async/await library, I noticed that I was
often forced to parenthesize yield expressions as (yield exp) because of
the low precedence of the yield operator. Typical patterns are:

var foo = (yield a()) + (yield b()) + (yield c());
if ((yield a()) && cond2 ...) ...

Looks more LISPish than JSish to me.

The low precedence plays well with yield _statements_, as it lets you write
  yield a + b;
very much like you would write
  return a + b;

But it does not play as well with yield _expressions_.

The only solutions I can think of would be to have a different keyword for
yield _expressions_ (await?) with the same precedence as other unary
operators.

Anyway, this is only a small annoyance and I know it's getting late into
the game. But I thought I'd raise the issue anyway.

Bruno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130614/957edab7/attachment.html>


More information about the es-discuss mailing list