while Statement Examples
|
while (true) a++;
a is increment definitively! while (n-) a++; an error is raised: boolean expected, got integer while (n- > 0) a++; this is better while (n++ <= 100 || stop) {if (!perform(a++)) break; check(a);} note the usage of a compound statement and of the break while (name != "john") {l := (select Person.name = name); name := get_name();} no comments |
do/while Statement Examples
|
do a++; while (true);
a is increment definitively! do a=+; while (n-); an error is raised: boolean expected, got integer do a++; while (n- > 0); this is better do {if (!perform(a++)) break; check(a);} while (n++ <= 100 || stop); note the usage of a compound statement and of the break do {l := (select Person.name = name); name := get_name();} while (name != "john"); no comments |
C-for Statement Examples
|
for (x := 0; x < 100; x++) a++;
increment a an hundred times for (x := 0, y := 1; x < 100 && check(y); x++) {y := get(y); if (y == 9999) break;} a more complex example for (x := 100; x; x-) perform(x); raises an error: boolean expected, got integer for (x := 0;;) doit(); note that there is neither a conditionnal expression, nor a second expression for (;;) doit(); same as while(true) |
collection-for Statement Examples
|
for (x in list(1, 2, 3)) a += x;
increments a with 1, 2 and 3 for (x in (select Person)) names += x.name; concatenates all the person names for (x in (select Person.name = "john")) if (x.age < 10 || x.spouse.age < 10) throw "cannot mary children!!"; a moralistic example for (x in 1) doit(); raises an error: boolean expected, got integer |
EyeDB manual