Brendan Eich (2013-06-14T18:07:48.000Z)
github at esdiscuss.org (2013-07-12T02:27:36.815Z)
Bruno Jouhier wrote: > 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: > > ```js > var foo = (yield a()) + (yield b()) + (yield c()); > ``` That's actually a hard case, IMHO -- and "hard cases make bad law". Many programmers would rather have the extra parens for uncertain cases (C's misplaced bitwise-logical and shift operators, vs. equality/relational; anything novel such as yield). But the real reason for yield being low precedence is to avoid precedence inversion. Consider if yield could be high-precedence, say a unary operator like delete: ```js let x = yield a + b; ``` Oops, many people would want that to be equivalent to ```js let x = yield (a + b); ``` but if yield is at delete's precence level, it's rather: ```js let x = (yield a) + b; ``` Which is the rare ("hard", from law school) case. For commutative operators such as +, over-parenthesizing is better again, because ```js let x = b + (yield a); ``` and ```js let x = (yield a) + b; ``` ignoring order of effects in shared mutable store, and ignoring floating point non-determinism, are equivalent.