Jason Orendorff
unread,Feb 2, 2012, 1:28:39 PM2/2/12You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to dev-tech-js-en...@lists.mozilla.org
This is so neat I have to share...
Brendan tweeted that TC39 is considering making this code:
for (let i = 0; i < 10; i++)
setTimeout(function () { alert(i); }, 0);
work as expected, alerting each digit in turn, instead of alerting "10"
ten times.
I think this is really easy to implement in SpiderMonkey! Currently we
emit bytecode like this:
for (let V = INIT; TEST; UPD) STMT
INIT
enterlet V
goto L2
L1: STMT
UPD
L2: TEST
iftrue L1
leaveblock
The new way only requires one tiny change: add a "reenterblock"
instruction between STMT and UPD! The new instruction would just exit
the current block, then do the exact same thing as "enterlet V". All the
code already exists.
-j