// Example code. // - NOTE: The syntax is very likely to change, and this may be not // up-to-date. function square(int n) = ($n * $n) function f(int x, int y, str s, bool b) = ( $x + 4 * ($y + 5) == $y - $x + 4 || $b && (int $s == $x || $s == str $x) ) // Recursion. function f(int n) = (n + f n); procedure int p(str x, int n, bool b) { int ret; // Pass $x into `sed`, store result in $s. s <= @sed "-E" "s/x/y/g" <= $x; // Pass $x into grep, get return code. ret <- @grep "-qE" "x" <= $s; if ($ret == 0 && b) { return 0 /* return/exit code */, int $x /* return value */; } else { return 1, 0; } } procedure int q() { str s; read_line $s; print $s; print_err $s; return 0, 42; } procedure int r() { int ret; str stdout, stderr; int value; // Evaluate an expression. value = square 7 - 5; // Get all data from a procedure call. (ret, value, stdout, stderr) <- p "x" 42 (3 == 4) <= "stdin"; // Minimal procedure call. // - stdout, stderr, stdin are passed through. // - Non-zero return code causes this procedure to return with that return // code. q; // Get some data from a procedure call. // - `:` means pass through, `_` means ignore. (ret, value) <- q; (ret, _, :, stderr) <- q; (value, stdout, stderr) <= q; value <= q; (value, stdout) <= q; (_, stdout) <= q; return 0, $value; } procedure main() { while true { @date "-u"; r; } return 127; // no return value, only return code } // vi: ts=2 sw=0 et