While Let
Common syntax
print x
x + 1
/while
To increment a variable, Scriptol uses x + 1.
This could not work in C and other languages.
Infinite loop in C
The C and C-like languages (C++, Java, C#) leads easily into infinite loop. Here hare two simple examples.
{
printf("%d\n", x);
x += 1:
}
Perhaps you have instantaneously noticed it (and perhaps no), but
the construct is bad, due to the semi-colon after the condition!
Another example without the misplaced semi-colon:
>
{
printf("%d\n", x);
if(x = 5) continue;
... some statements ...
x += 1;
}
Once x reaches a value of 5, the counter never can change, because incrementing is skipped by the "continue" statement, and the loop never can stop.
While let
Scriptol uses a secure syntax to prevent infinite loop:
print x
if x = 5 continue
... some statements ...
let x + 1
In Scriptol, the "continue" statement jumps to the "let" statement, and the variable is incremented in this statement.