F.E.L.T.

Functionally Equivalent Language Translation

WHILE

(while condition body)
(defvar i 0)
(while (decf i)
 (emit "Not there yet: " i "\n"))

See also UNTIL FOR FOREACH

This is a looping iterator that performs the conditional test before the execution of the body content.


To avoid confusion about do...while and while...do constructs, FELT uses the instruction name UNTIL to indicate that the body will be executed at least once before the condition is checked. In other words, the UNTIL instruction is the class do...while after all but hopefully has a clearer name.

Here is a simple example that counts from zero to 9, the FELT source:

(defvar x 0)
(while (< x 10)
  (emit "x is: " (incf x) "\n"))

and here is the translated PHP:

$x = 0;
while(($x) < (10)) {
  echo "x is: ", ($x++), "\n";
}

and the JavaScript (Node) code too:

var x = 0;
while((x) < (10)) {
  console.log("x is: "+ (x++)+ "\n");
}