Why can’t for-of be applied to iterators?
brendan at mozilla.com
Tue Jun 11 12:19:52 PDT 2013
Andreas Rossberg wrote:
> On 11 June 2013 14:50, Tab Atkins Jr.<jackalmage at gmail.com> wrote:
>> On Tue, Jun 11, 2013 at 2:08 AM, Axel Rauschmayer<axel at rauschma.de> wrote:
>>> And it becomes harder to distinguish the interfaces, should you
>>> need to . IMO, the purity argument also counts: this technique implies
>>> that iterators are a subset of iterables, but that isn’t true: For
>>> iterables, each invocation of `iterator` creates a new object, for
>>> iterators, it doesn’t.
>> As noted in the first comment, it's trivial to check for the
>> difference in all well-behaved cases by just seeing if "obj ===
>> obj[iterator]()" is true or false.
> That makes a terrible API, though. I think Axel has a valid point that
> the distinction between iterators and iterables is fuzzy enough to be
> more confusing and error-prone than useful.
Have you actually used Python or JS1.7 much, though?
Have to ask, since throwing "confusing" and "error-prone" charges
demands evidence or at least anecdotes.
More information about the es-discuss