Jason Orendorff wrote:
If so, how? Didn't the committee also decide not to give Iterables or Iterators a common prototype, or define these methods as part of the Iterator or Iterable interface?
The plan is to leave the iteration protocol "duck-typed" or "structural", but enable reuse of common array-extra-like methods via Iterator.prototype (which will be on the generator iterator objects' prototype chains).
The Iterator function can be used as an adaptor, to go from any old iterator (duck-typed) to an instance of the nominal type.
This isn't an attempt to force nominal-only iteration (I checked, as you would expect!). It's an "adaptor" pattern we see in lots of places in JS, which gives a prototypal home for the "itertools" methods. Methods, not functions, because JS has both but favors methods in most of its libraries starting with the stdlib.
/be _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss