Closed
Bug 1217072
Opened 9 years ago
Closed 9 years ago
Remove use of for-each from addon-sdk/.
Categories
(Add-on SDK Graveyard :: General, defect)
Add-on SDK Graveyard
General
Tracking
(firefox44 fixed)
RESOLVED
FIXED
mozilla44
Tracking | Status | |
---|---|---|
firefox44 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(1 file)
5.99 KB,
patch
|
mossop
:
review+
|
Details | Diff | Splinter Review |
Need to replace non-standard for-each with one of: * for-of * for-in * array.map/array.filter for array-comprehension as a part of bug 1083470. converting rules are following: * for-each * for each (let x in array) { ... } -> for (let x of array) { ... } * for each (let x in object) { ... } -> for (let key in object) { let x = object[key]; ... } * for each (let [key, value] in Iterator(object)) { ... } -> for (let key in object) { let value = object[key]; ... } * for each (let x in array) { ... } where array can be null or undefined -> if (array) { for (let x of array) { ... } } * legacy array comprehension with for-each * [EXPR for each (x in array)] -> array.map(x => EXPR) * [EXPR for each (x in array) if (COND)] -> array.filter(x => COND).map(x => EXPR) * [x for each (x in array) if (COND)] -> array.filter(x => COND) * [EXPR for each ([i, x] in Iterator(array)) if (g(x, i)] -> array.filter((x, i) => g(x, i)).map((x => EXPR) * [EXPR for each (x in arraylike)] -> Array.from(arraylike).map(x => EXPR) * [EXPR for each (x in string)] -> Array.prototype.slice.call(string).map(x => EXPR) // Array.from behaves differently for surrogate-pair I'll post a patch shortly.
Assignee | ||
Comment 1•9 years ago
|
||
try runs here linux: https://treeherder.mozilla.org/#/jobs?repo=try&revision=f521b1264cb4 mac (after linux with some fix): https://treeherder.mozilla.org/#/jobs?repo=try&revision=d5ecb19c84f6 win (after mac with some fix): https://treeherder.mozilla.org/#/jobs?repo=try&revision=adf800f88efd finally xpcshell passed on linux (after win with some fix): https://treeherder.mozilla.org/#/jobs?repo=try&revision=526c234c897d
Attachment #8676972 -
Flags: review?(dtownsend)
Assignee | ||
Comment 2•9 years ago
|
||
I didn't replace this line, as it looks like it's testing behavior for for-each. https://dxr.mozilla.org/mozilla-central/rev/605de27d4e7f530159842649c02075c578d7a4a5/addon-sdk/source/test/test-api-utils.js#307 > for each (let val in obj) > valsItr.push(val); I think this should be removed at the same time as removing for-each support from SpiderMonkey.
Comment 3•9 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #0) > * legacy array comprehension with for-each > * [EXPR for each (x in array)] > -> array.map(x => EXPR) > * [EXPR for each (x in array) if (COND)] > -> array.filter(x => COND).map(x => EXPR) > * [x for each (x in array) if (COND)] > -> array.filter(x => COND) > * [EXPR for each ([i, x] in Iterator(array)) if (g(x, i)] > -> array.filter((x, i) => g(x, i)).map((x => EXPR) > * [EXPR for each (x in arraylike)] > -> Array.from(arraylike).map(x => EXPR) > * [EXPR for each (x in string)] > -> Array.prototype.slice.call(string).map(x => EXPR) > // Array.from behaves differently for surrogate-pair Why aren't we switching to the new form of array comprehensions for these?
Flags: needinfo?(arai.unmht)
Assignee | ||
Comment 4•9 years ago
|
||
because it's removed from the spec (iiuc, even from ES7).
Flags: needinfo?(arai.unmht)
Assignee | ||
Comment 5•9 years ago
|
||
"removed from ES7" seems to be somewhat wrong, but it looks like there will be some change in syntax and semataics, and we shouldn't use it for now. https://esdiscuss.org/topic/array-comprehensions-with-spread-operator https://github.com/rwaldron/tc39-notes/blob/c61f48cea5f2339a1ec65ca89827c8cff170779b/es6/2014-06/jun-5.md#generator-comprehensions-slides-plz https://speakerdeck.com/dherman/a-better-future-for-comprehensions https://github.com/tc39/ecma262 https://tc39.github.io/ecma262/ I'll post when I get more information.
Assignee | ||
Comment 6•9 years ago
|
||
array comprehension and generator comprehension are not likely to be added to the spec, and we'll eventually remove it from SpiderMonkey if we can. I've just updated documentation on MDN from experimental to non-standard. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Generator_comprehensions let's go with map/filter :)
Updated•9 years ago
|
Attachment #8676972 -
Flags: review?(dtownsend) → review+
Assignee | ||
Comment 7•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/a2965479d63d09610308518d03aa63a2957c29f4 Bug 1217072 - Remove for-each from addon-sdk/. r=mossop
https://hg.mozilla.org/mozilla-central/rev/a2965479d63d
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox44:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in
before you can comment on or make changes to this bug.
Description
•