Why no tail calls from generators?

Bergi a.d.bergi at web.de
Wed Oct 12 20:03:15 UTC 2016

Joe Gibbs Politz wrote:

> What is the rationale for explicitly disallowing PTC in generators?  (Or,
> in the case of proposals like STC, why not allow users to opt in to TCO in
> generator bodies?)

I'd guess that generator functions are already complicated enough, and 
the `next()` call that at least has to wrap the result in `{value: …, 
done:true}` would always have to stay on the stack.
However, it would be possible to do tail-recursive calls in generator 
functions via

     return yield* f(…)

Kind regards,

More information about the es-discuss mailing list