Why do generator expressions return generators?
rossberg at google.com
Fri Sep 6 09:50:17 PDT 2013
On 6 September 2013 18:04, Brendan Eich <brendan at mozilla.com> wrote:
> The spec does not use desugaring, of course. While it could be done, in a
> debugger the results would differ observably from a generator function with
> let bindings. I think the spec should talk about this level of observability.
But it doesn't. No matter which way you spec it, AFAICT, the
difference is not observable from within the (spec'ed) language. We
don't spec a debugger. Moreover, such details will already be
dependent on implementation and optimisation anyway. So that does not
strike me as a compelling argument. (If the spec really cared to guide
debuggers, some notes could take care of that, but I don't think it
makes sense to even try.)
The price for not applying desugaring techniques is that we are
pulling in a lot of unnecessary complexity and accidental
inconsistency. I think it's quite a substantial cost, actually.
Desugaring also is a great way of dog-fooding your own abstraction
capabilities -- it can reveal language deficiencies quite
[I guess your "of course" activated my ranting trigger here, given
that small core languages plus well-defined desugarings were still
regarded best practice last time I looked. ;)]
More information about the es-discuss