loop unrolling and completion values in ES6

Alan Schmitt alan.schmitt at polytechnique.org
Tue Apr 7 14:09:12 UTC 2015

Hi Allen,

On 2015-04-06 02:08, Allen Wirfs-Brock <allen at wirfs-brock.com> writes:

> Alan,
> I freed up a couple minutes for a quick look at this. I want to spend some
> more time look at it deeper as this is an area where I made some fixes just
> a couple weeks ago and I want to review them again to make sure everything is
> as intended.
> But, for now a quick answer to your question is:  yes there is an intentional difference.
> For blocks that are not part of loops (and top level StatementLists) we wanted
> to preserve the legacy completion values described in the NOTE at the end of
> 13.1.13. this requires preserving empty completion values originating from
> stand-alone blocks. However, we also wanted all control flow statements to
> always produce a non-emptry completion value.

I understand. In fact, it seems that this particular behavior did not
change between ES 5 and ES 6: block evaluation guarantees the last value
computed is returned, whereas loops don't. According to my tests,
neither V8 nor SpiderMonkey have this behavior:

var c; a: { c = 1; while(true) { if (c) { c=0; } else { break a; } } }

returns 0 in both, whereas the spec says it should be 1 (caveat:
I tested in a current Chrome and Firefox browsers, I don't know if it's
the correct environment to do such tests).

Does this inconsistency matter?



OpenPGP Key ID : 040D0A3B4ED2E5C7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 494 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150407/5a24c6c3/attachment.sig>

More information about the es-discuss mailing list