Closed
Bug 926685
Opened 13 years ago
Closed 12 years ago
ForOfIterator comment is out of date
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: jorendorff, Unassigned)
References
Details
The comment on ForOfIterator in jsiter.h says:
> * Convenience class for imitating a JS level for-of loop. Typical usage:
> *
> * ForOfIterator it(cx);
> * if (!it.init(iterable))
> * return false;
> * RootedValue val(cx);
> * for (;;) {
> * if (!next(&val, &done))
> * return false;
> * if (!DoStuff(cx, val))
> * return false;
> * }
> *
Unfortunately it is not that simple. Real usage is like this:
ForOfIterator it(cx);
if (!it.init(iterable))
return false;
RootedValue val(cx);
bool done;
for (;;) {
if (!next(&val, &done))
return false;
if (done)
break;
if (!DoStuff(cx, val))
return false;
}
The comment should be fixed. Ideally the API could be streamlined:
ForOfIterator it(cx);
if (!it.first(iterable))
return false;
while (!it.done) {
if (!DoStuff(cx, it.value))
return false;
if (!it.next())
return false;
}
| Assignee | ||
Updated•12 years ago
|
Assignee: general → nobody
Comment 1•12 years ago
|
||
This got fixed in bug 952873.
You need to log in
before you can comment on or make changes to this bug.
Description
•