Iterators, generators, finally, and scarce resources (Was: April 10 2014 Meeting Notes)

Andreas Rossberg rossberg at google.com
Wed Apr 30 03:48:11 PDT 2014


On 29 April 2014 20:35, David Herman <dherman at mozilla.com> wrote:
> On Apr 29, 2014, at 12:40 AM, Andy Wingo <wingo at igalia.com> wrote:
>> Indeed I expect that in
>> practice most iterators in an ES6 program will be map, set, and array
>> iterators, which in practice will not be implemented with generators.
>
> I strongly disagree with this. Generators will by far be the most convenient and common way to implement iterators, regardless of their data source.

Yes, but Andy was talking about VM-provided iterators, where
convenience of implementation does not matter. It is safe to assume
that for all VMs a generator-based implementation will be
substantially more expensive than a hand-written one (and will remain
so in the foreseeable future, I'm pretty sure of that -- e.g. inlining
is tricky for generators). So VM implementers won't use generators
internally.

/Andreas


More information about the es-discuss mailing list