Logical time

ReactiveML is based on the synchronous model. In this model, time is a succession of instants. Any OCaml function is considered to be instantaneous.

let instantaneous_loop n =
  for i = 1 to n do
    print_int i; print_newline ()
  done ;;

instantaneous_loop 10;;

Functions that can be executed through several instants are called processes. The pause statement waits for the next instant.

let process non_instantaneous_loop n =
  for i = 1 to n do
    print_int i; print_newline ();
    pause
  done ;;

To apply a process, we have to use the run keyword. Such an expression that takes time has to be executed in the background of the terminal using the #exec directive:

#exec (run (non_instantaneous_loop 10));;

Remark: You can use the "suspend" button (or the directive #suspend;;) to execute the program step by step. To return to the sampled mode you can use the "resume" button (or the directive #resume;;).