iterate and enumerate trap signature inconsistency
bruant.d at gmail.com
Sun Sep 2 11:13:25 PDT 2012
The enumerate (for..in loops) and iterate (for..of loops) traps have
inconsistent signatures. The former needs an array of strings to be
returns, the latter an iterator.
I would tend to be in favor of both returning an iterator to avoid
allocating, filling & freeing memory in case of recurrent for..in/of
loops on the object. It's also somewhat more aligned with the idea of a
loop: if the loop contains a 'break' statement, in the array case, some
memory is left unused, but in the iterator case, the iterator just stops
being called if control gets out of the loop.
By the way, what's the difference between an iterator and a generator?
Would it make sense that both traps return a generator rather than an
More information about the es-discuss