Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upEnumerate iterator shape somewhat ambiguous? #74
Comments
bterlson
added
question
editorial change
labels
Sep 30, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Oct 1, 2015
Member
Nope, the intent is yes and yes. For example, if the informative generator definition was used in the [[Enumerate]] definition, the iterator returned would be a generator object and you would have the yes, yes condition.
Basically, 9.1.11 means exactly and only what it says. The object must inherit from %IteratorPrototype% but not necessarily directly and it must implement the Iterator interface but not necessarily using own properties.
Note that ordinary object property enumeration has always been very implementation dependent and, at least for ES6, TC39 was brave enough to try to precisely specify it.
|
Nope, the intent is yes and yes. For example, if the informative generator definition was used in the [[Enumerate]] definition, the iterator returned would be a generator object and you would have the yes, yes condition. Basically, 9.1.11 means exactly and only what it says. The object must inherit from %IteratorPrototype% but not necessarily directly and it must implement the Iterator interface but not necessarily using own properties. Note that ordinary object property enumeration has always been very implementation dependent and, at least for ES6, TC39 was brave enough to try to precisely specify it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Oct 1, 2015
Member
Yes good point about how this API would look if implemented as a generator. Maybe spec should actually say that instead? It seems strange to not be precise about the shape of the object returned here. I don't see how object property enumeration being historically implementation dependent is relevant - this is about the shape of the iterator we return for the Enumerate internal op (and as returned by Reflect.enumerate(obj)) which seems orthogonal to previous enumeration order concerns. Can you clarify?
|
Yes good point about how this API would look if implemented as a generator. Maybe spec should actually say that instead? It seems strange to not be precise about the shape of the object returned here. I don't see how object property enumeration being historically implementation dependent is relevant - this is about the shape of the iterator we return for the Enumerate internal op (and as returned by |
bterlson
added
normative change
and removed
editorial change
labels
Oct 1, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Oct 22, 2015
Member
I guess I'm the only one uncomfortable with this, so closing for now.
Although I do note that FF and Edge are going to agree on Empty object, Object with .next property, %IteratorPrototype%, %ObjectPrototype%.
|
I guess I'm the only one uncomfortable with this, so closing for now. Although I do note that FF and Edge are going to agree on Empty object, Object with .next property, %IteratorPrototype%, %ObjectPrototype%. |
bterlson
closed this
Oct 22, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Wait, doesn't the spec require that |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Oct 22, 2015
Member
No. %IteratorPrototype% only has a Symbol.iterator property. The spec requires that a next property exists somewhere in the prototype chain but says nothing about where.
|
No. %IteratorPrototype% only has a Symbol.iterator property. The spec requires that a next property exists somewhere in the prototype chain but says nothing about where. |
bterlson commentedSep 30, 2015
9.1.1 says only that the object must be an iterator and that it must inherit from %IteratorPrototype%. Leaves me wondering:
nextproperty be a prototype property of the returned object?I would hope the answers to these are no and no. In either case, the spec text could probably be improved to clarify.