Update/data after talking with sfink/jorendorff/Waldo/shu of the JS team
and some follow-up investigation with thanks to sfink to initiating the
conversation:
- yield inside function* is working fine inside a worker with
JSVERSION_DEFAULT; we suspect the error I was relaying was not inside a
function* usage during the initial debugging cycle where this all came
up. My apologies to anyone temporarily misled.
- "lexicals" (both "let" and "const") are expected to be in good shape
at the end of Q2 (end of June) if all goes well, although these things
are complex and it would not be surprising for complications to arise
that cause it to take longer.
- Aspects of "let"/"const" seem like they work with JS1.7/JS1.8 enabled
do not in fact work yet and this constitutes a bit of a foot-gun that
would be a bad idea to enable until they work.
For example, given the function:
function danger(bob) { for (let foo of bob) { window.setTimeout(() =>
{ console.log(foo) }, 0); } }
and then doing:
danger([1, 2])
prints: "2" followed by "2", just like if you had used "var".
But the older-school for(let;;) that you may be used to from JS1.7/1.8
works and latches appropriately:
function safe(bob) { for (let iFoo=0; iFoo < bob.length; iFoo++) {
window.setTimeout(() => { console.log(bob[iFoo]); }, 0); } }
so doing:
danger([1, 2])
prints: "1" followed by "2"
- The recommendation for now is that if one must use the lexicals
let/const, then transpiling probably is the way to go. However, if you
can get by with "var" (which is faster/more optimized for now) and all
the stuff that works on main thread without specifying version=1.7/1.8,
then you should be fine and just stick with "var".
Andrew
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform