Precedence of yield operator
claude.pache at gmail.com
Sat Jun 15 07:20:12 PDT 2013
Le 15 juin 2013 à 10:18, François REMY <francois.remy.dev at outlook.com> a écrit :
> I'm maybe biased, but I would love to consider "yield" as a function. Indeed, it calls another code, which can return you a value. That looks very similar to a function call to me. If we do this, the predecence becomes intuitive again:
> var x = yield(a) + yield(b);
> I think there was a proposal to allow parenthesis-free function call at some point at the root of a statement. When it lands, you'll be able to do things like
> yield a+b;
> as a normal statement again. In the mean time we can just use parentheses, that's not a huge issue and it helps clarity.
> But maybe this is too late to change ES6, it's just an idea I had while reading this thread, not a strong call for change.
There is an issue when the argument of an intended parenthesis-free function call happens to begin with a parenthesis:
yield a*(b + c) <==> yield(a*(b + c))
yield (b + c)*a <==> (yield(b + c))*a instead of yield((b + c) *a)
More information about the es-discuss