<div dir="ltr"><div class="markdown-here-wrapper" style><blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:1.2em 0px!important">First, you shouldn’t assume this would be based on the Symbol.iterator protocol.</p>
</blockquote>
<p style="margin:1.2em 0px!important">Would <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Object.create(null, {[Symbol.iterator]: value: ...})</code> work as it does in for..of?</p>
<p style="margin:1.2em 0px!important">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).</p>
<p style="margin:1.2em 0px!important">If I do have an arbitrary iterable, I need to easily create something I can pass to for..of with <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">if (x of fn(xs))</code> where fn is provided by ecmascript.</p>
<div title="MDH:Jmd0O8KgPHNwYW4gc3R5bGU9ImZvbnQtc2l6ZTogMTIuODAwMDAwMTkwNzM0OXB4OyI+Rmlyc3Qs
IHlvdSBzaG91bGRuJ3QgYXNzdW1lIHRoaXMgd291bGQgYmUgYmFzZWQgb24gdGhlIFN5bWJvbC5p
dGVyYXRvciBwcm90b2NvbC48L3NwYW4+PGRpdj48c3BhbiBzdHlsZT0iZm9udC1zaXplOiAxMi44
MDAwMDAxOTA3MzQ5cHg7Ij48YnI+PC9zcGFuPjwvZGl2PjxkaXY+PHNwYW4gc3R5bGU9ImZvbnQt
c2l6ZTogMTIuODAwMDAwMTkwNzM0OXB4OyI+V291bGQgYE9iamVjdC5jcmVhdGUobnVsbCwge1s8
L3NwYW4+PHNwYW4gc3R5bGU9ImZvbnQtc2l6ZTogMTI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;font-size:0em;padding:0;margin:0">​</div></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 30, 2015 at 12:02 PM, Brendan Eich <span dir="ltr"><<a href="mailto:brendan@mozilla.org" target="_blank">brendan@mozilla.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>Michał Wadas wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
First possible problem - "of" used in if statement can put iterator in unexpected state or result in arbitrary side effects.<br>
</blockquote>
<br></span>
What iterator?<br>
<br>
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.<br>
<br>
Second, the iteration protocol would require exhaustively searching for values. Side effects of iteration are the least worry!<br>
<br>
Finally, even if the iteration protocol were used, there would be no shared/reused iterator. You get a fresh one from well-implemented iterables.<div><div><br>
<br>
/be<br>
______________________________<u></u>_________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" target="_blank">https://mail.mozilla.org/<u></u>listinfo/es-discuss</a><br>
</div></div></blockquote></div><br></div></div>