function foo() {
yield = some_computation();
return yield;
}
this code would be broken by enabling generators. Same with yield* foo() (which would be interpreted as multiplying the variable `yield` by the result of `foo()` in ES5).It also creates a nice parallelism between function* and yield, as a side-effect.
See http://esdiscuss.org/topic/proposal-to-simplify-generators-i..., there should be more extensive previous discussions in es-discuss and TC39 notes but it's a pain in the ass to look it up.
edit: https://mail.mozilla.org/pipermail/es-discuss/ also points to the use case of 0-item generators — mostly in relation to delegating from yield — with
function* () {}
in Python (and JS/1.7) you'd need the unwieldy function() {
if (false) yield
}
and notes that having a star in the header function makes it easier on the reader.