Replace E4X for-each with ES6 for-of in Add-on SDK and chrome JS

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
3 years ago

People

(Reporter: evilpie, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Comment hidden (empty)
(Reporter)

Comment 1

5 years ago
Created attachment 816253 [details] [diff] [review]
remove for each from dom/

https://tbpl.mozilla.org/?tree=Try&rev=97881b867db2
Assignee: nobody → evilpies
Status: NEW → ASSIGNED
Attachment #816253 - Flags: review?(Ms2ger)
(Reporter)

Comment 2

5 years ago
I have a few more patches, but they are really huge. Somebody wants to volunteer? They touch a lot of files in different components.
I can review some.  Are all the transformations just turning this:

  for each (let X in Y)

into this

  for (let X of Y)

or are there other forms?
(Reporter)

Comment 4

5 years ago
I think in practice this should work, but there might be some differences.
(Reporter)

Comment 5

5 years ago
17:52 <evilpie> jorendorff: what are the differences beween for each and for of?
17:52 <evilpie> seems like only a custom iterator property?
17:52 <jorendorff> evilpie: for-each iterates over *properties*
17:54 <jorendorff> evilpie: for-of iterates over whatever obj.iterator() returns, so types like Map and Set, and generators, which don't treat their contents as properties, can still be iterable
17:54 <jorendorff> sorry
17:54 <jorendorff> obj[std_iterator]()
17:55 <jorendorff> (it should've been called .iterator() but TC39 <3 symbols)
17:56 <evilpie> oh because for each (x in {a: 1}) {} works
17:56 <sankha93> what is difference between the @@iterator and the symbol?
17:56 <evilpie> so we need to be careful to use Iterator() or something in that case
If for-each is used on an array then it can usually be changed to for-of easily. If for each is used on any other type of object, then the transformation looks like, from:

> for each (let value in obj) {

to:

> for (let key in obj) {
>   let value = obj[key];
I've put the existing bugs that are "remove for each from ..." as blockers for this. Feel free to do this all as part of one big patch or however you want to do it, just wanted to make sure they get closed if they're fixed when this is fixed.
Depends on: 866733, 825800, 825801
(Reporter)

Comment 8

5 years ago
Verifying every single use and making sure that it is actually possible to convert to for .. of in a straightforward way almost seems like an impossible task.
(Reporter)

Updated

5 years ago
Assignee: evilpies → nobody
Status: ASSIGNED → NEW
(Reporter)

Updated

5 years ago
Attachment #816253 - Flags: review?(Ms2ger)
Duplicate of this bug: 791348
Blocks: 1083470
Depends on: 1083467
OS: Linux → All
Hardware: x86_64 → All
Summary: Replace for each with for of in Mozilla code → Replace E4X for-each with ES6 for-of in Add-on SDK and chrome JS
All blocking bugs are fixed and other use are also removed in other bugs that blocks bug 1083470.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.