-
Fri 2021.10.15
'Per the standard, the condition in loops is an Expression,'
Hi @user135362 when challenging referencing an outside document, providing the link to that document will assist us all in evaluating your concern.
As I see it:
The conditional expression for a while statement must evaluate true or false.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator
In the sample provided
x = costlyAccessor(i++)
will always evaluate TRUE based on the truthy rules. Result: endless loopAlso,
>while(0,0);
can never evalute TRUE. Result: never executesSo, as I see it, and as none of the references I have just found make any mention of using the comma operator within a while conditional, seems problematic.
Could be other reasons, but I'm sure this will open up to others for discussion. . . .
Per the standard, the condition in loops is an Expression, but Espruino evidently parses it as AssignmentExpression, disallowing the comma operator. This is particularly painful contexts like
Minimal reproduction:
Oddly, if and switch have no such problem.