We can notice that the three control structures (match/with,
automaton and present) combine equations. Each branch is
made of a set of equations defining shared values. In this form, it
is not necessary to give a definition for each shared variable in all the
branches: a shared variable implicitely keeps its previous value or
is absent if it is defined as a signal.
We have adopted this syntactical convention to be close to the graphical representation of programs in synchronous dataflow tools (such as Scade/Lustre). In such tools, control structures naturally combine (large) sets of equations and the implicit completion of absent definitions is essential.
The language also provides a derived form for control structures allowing them to be used as expressions. For example:
let node expect x =
automaton
Await -> false unless x then One
| One -> true
end
is a short-cut for:
let node expect x =
let automaton
Await -> do o = false unless x then One
| One -> do o = true done
end in
o
In the same way:
let node two x =
match x with
true -> 1
| false -> 2
end
as a short-cut for:
let node two x =
let match x with
true -> do o = 1 done
| false -> do o = 2 done
end in
o
thus leading to a more conventional notation for the Objective Caml programmer.