Scriptol/While Let
外觀
< Scriptol
while x < 5 print x x + 1 /while
為了遞增變數,Scriptol 使用 x + 1。這在 C 和其他語言中行不通。
C 和類似 C 的語言(C++、Java、C#)很容易導致無限迴圈。這裡有兩個簡單的例子。
while(x < 5);
{
printf("%d\n", x);
x += 1:
}
也許你已經瞬間注意到了(也許沒有),但這個結構很糟糕,因為條件後面有分號!
另一個沒有放置錯誤分號的例子
while(x < 10)
{
printf("%d\n", x);
if(x = 5) continue;
... some statements ...
x += 1;
}