The spec seems to describe completion values in loops in a confusing and
possibly incorrect way that is different from what Mozilla does.
Here is a loop, where I would expect the completion value to be 17, and
this is indeed what Mozilla returns when the code is evaled():
x = true;
outer: while(x) {
99;
while (true) {
if (!x) continue outer;
x = false;
17;
}
}
However, following the spec it would seem like it should be 99.
The inner loop ends with a continue statement that will return an abrupt
completion with no value. In both ECMA-262-3 and ECMA-262-5 abrupt
completions are returned immediately as is, and the completion value
from the last loop iteration is not returned.
I've got some escaped code here for anyone who wants to try it:
y = eval("x = true;"+
"outer: while(x) {"+
" 99;"+
" while (true) {"+
" if (!x) continue outer;"+
" x = false;"+
" 17;"+
" }"+
"}");
alert(y);
The relevant section of the spec is "12.6.2 The while statement".
Any guidance on this matter would be gratefully appreciated.
Best ,
Michael
Hi,
The spec seems to describe completion values in loops in a confusing and
possibly incorrect way that is different from what Mozilla does.
Here is a loop, where I would expect the completion value to be 17, and
this is indeed what Mozilla returns when the code is evaled():
x = true;
outer: while(x) {
99;
while (true) {
if (!x) continue outer;
x = false;
17;
}
}
However, following the spec it would seem like it should be 99.
The inner loop ends with a continue statement that will return an abrupt
completion with no value. In both ECMA-262-3 and ECMA-262-5 abrupt
completions are returned immediately as is, and the completion value
from the last loop iteration is not returned.
I've got some escaped code here for anyone who wants to try it:
y = eval("x = true;"+
"outer: while(x) {"+
" 99;"+
" while (true) {"+
" if (!x) continue outer;"+
" x = false;"+
" 17;"+
" }"+
"}");
alert(y);
The relevant section of the spec is "12.6.2 The while statement".
Any guidance on this matter would be gratefully appreciated.
Best regards,
Michael
--
Print XML with Prince!
http://www.princexml.com
The spec seems to describe completion values in loops in a confusing and possibly incorrect way that is different from what Mozilla does.
Here is a loop, where I would expect the completion value to be 17, and this is indeed what Mozilla returns when the code is evaled():
x = true; outer: while(x) { 99; while (true) { if (!x) continue outer; x = false; 17; } }
However, following the spec it would seem like it should be 99.
The inner loop ends with a continue statement that will return an abrupt completion with no value. In both ECMA-262-3 and ECMA-262-5 abrupt completions are returned immediately as is, and the completion value from the last loop iteration is not returned.
I've got some escaped code here for anyone who wants to try it:
y = eval("x = true;"+ "outer: while(x) {"+ " 99;"+ " while (true) {"+ " if (!x) continue outer;"+ " x = false;"+ " 17;"+ " }"+ "}");
alert(y);
The relevant section of the spec is "12.6.2 The while statement".
Any guidance on this matter would be gratefully appreciated.
Best ,
Michael