Closed
Bug 666404
Opened 13 years ago
Closed 11 years ago
allow returning values from generators
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: dherman, Unassigned)
References
(Blocks 1 open bug, )
Details
Harmony is extending generators to allow them to return values, similarly to Python's PEP 380. One API detail that hasn't been worked out: presently our generators throw StopIteration when a generator returns. We want to preserve that the following two statements are equivalent: return; return (void 0); but if StopIteration becomes a constructor that wraps a value, then we'll be incompatible with existing SpiderMonkey code that tests (e === StopIteration). We could special-case the StopIteration function to produce itself when called on the undefined value, but that's a little warty if it's just being done for Firefox backwards-compatibility. I'll do some spelunking through the Firefox codebase and the addons to see how often code is comparing StopIteration via === or ==, to try to get some data. Dave
Comment 1•11 years ago
|
||
This bug is probably moot with the updated iterator protocol where each iteration returns an object. In a generator: > yield 5; > //-> { done: false, value: 5 } > return 5; > //-> { done: true, value: 5 } rendering ES6 iterators/generators completely incompatible with JS1.8 ones.
Comment 2•11 years ago
|
||
I think this can be resolved WORKSFORME with star generators having been mostly landed.
Comment 3•11 years ago
|
||
ES6 generators have been fully implemented now, resolving this.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•