`of` operator ES7 proposal from Ian Bicking

Frankie Bagnardi f.bagnardi at gmail.com
Mon Mar 30 19:24:22 UTC 2015

First, you shouldn’t assume this would be based on the Symbol.iterator

Would Object.create(null, {[Symbol.iterator]: value: ...}) work as it does
in for..of?

It seems like the main problem would be infinite sequences. That means
either infinite loops (ugh), or the language/user setting an arbitrary
number of max values to check (ew).

If I do have an arbitrary iterable, I need to easily create something I can
pass to for..of with if (x of fn(xs)) where fn is provided by ecmascript.

On Mon, Mar 30, 2015 at 12:02 PM, Brendan Eich <brendan at mozilla.org> wrote:

> Michał Wadas wrote:
>> First possible problem - "of" used in if statement can put iterator in
>> unexpected state or result in arbitrary side effects.
> What iterator?
> First, you shouldn't assume this would be based on the Symbol.iterator
> protocol. I wrote something like @@hasInstance for instanceof was the
> precedent to follow.
> Second, the iteration protocol would require exhaustively searching for
> values. Side effects of iteration are the least worry!
> Finally, even if the iteration protocol were used, there would be no
> shared/reused iterator. You get a fresh one from well-implemented iterables.
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150330/0f5120af/attachment.html>

More information about the es-discuss mailing list