generator function requirements

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Mon Apr 13 02:11:41 UTC 2015


On Sun, Apr 12, 2015 at 4:53 PM, Rick Waldron <waldron.rick at gmail.com>
wrote:

>
>
> On Sun, Apr 12, 2015 at 11:59 AM Mark Volkmann <r.mark.volkmann at gmail.com>
> wrote:
>
>> I couldn't find this in spec. Is it required for generator functions to
>> return an object that is both iterable (has Symbol.iterator method) and an
>> iterator (has next method). It seems Babel does this, but I want verify
>> whether that is required.
>>
>
> The object that's returned by a generator function conforms to both the
> Iterator and Iterable interfaces.
>
>
As any other iterator of the built-ins (unless I'm not aware of specific
cases). I.e. an enough description is: an object is returned by a generator
function is an _iterator_ (and that it conforms also the iterable
interfaces this should go without saying, since all iterators do;
user-level iterators may deviate from this "invariant" though).

Dmitry


> -
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iterable-interface
> -
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iterator-interface
>
> Rick
>
>
> _______________________________________________
> 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/20150412/bcc65f7b/attachment.html>


More information about the es-discuss mailing list