Merge branch 'master' of git.martlubbers.net:msc-thesis1617
[msc-thesis1617.git] / mtask.control.tex
1 Looping of \glspl{Task} happens because \glspl{Task} are executed after waiting
2 a specified amount of time or when they are launched by another \gls{Task} or
3 even themselves. Therefore there is no need for loop control flow functionality
4 such as \emph{while} or \emph{for} constructions. The main control flow
5 operators are the sequence operator and the \emph{if} statement. Both are shown
6 in Listing~\ref{lst:control}. The first class of \emph{If} statements describes
7 the regular \emph{if} statement. The expressions given can have any role. The
8 functional dependency on \CI{s} determines the return type of the statement.
9 The listing includes examples of implementations that illustrate this
10 dependency. A special \emph{If} statement --- only used for statements --- is
11 also added under the name \CI{IF}, of which the \CI{?} is a conditional
12 statement to execute.
13
14 The sequence operator is straightforward and its only function is to tie
15 two expressions together. The left expression is executed first, followed by
16 the right expression.
17
18 \begin{lstlisting}[language=Clean,%
19 label={lst:control},caption={Control flow operators}]
20 class IF v where
21 IF :: (v Bool p) (v t q) (v s r) -> v () Stmt | ...
22 (?) infix 1 :: (v Bool p) (v t q) -> v () Stmt | ...
23
24 class seq v where
25 (:.) infixr 0 :: (v t p) (v u q) -> v u Stmt | ...
26 \end{lstlisting}