You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GeneratorsFunctions could theoretically throw an error at any time! In addition, they do always return something, even if it's undefined. Therefore, simply extending Iterator isn't specific enough.
So why not make throw and return required properties of Generator?
A Generator object is an instance of a generator function and conforms to both the Iterator and Iterable interfaces.
However, I'd argue that a more specific implementation of Iterator still conforms to Iterator :)
The text was updated successfully, but these errors were encountered:
rclmenezes
changed the title
Suggestion: make generators return a new type of class that extends Iterator
Suggestion: make throw and return required fields for Generators
Feb 1, 2018
rclmenezes
changed the title
Suggestion: make throw and return required fields for Generators
Suggestion: make throw and return required fields for generators
Feb 1, 2018
Currently, GeneratorFunctions return a Generator, which simply extends Iterator:
This is unfortunate because
next
andthrow
are optional in Iterators:GeneratorsFunctions could theoretically throw an error at any time! In addition, they do always return something, even if it's undefined. Therefore, simply extending Iterator isn't specific enough.
So why not make
throw
andreturn
required properties of Generator?The current situation causes some rather frustrating problems. For example, this ticket.
True, the ECMA2015 schema says:
However, I'd argue that a more specific implementation of Iterator still conforms to Iterator :)
The text was updated successfully, but these errors were encountered: