summaryrefslogtreecommitdiff
blob: f99a1cf551a8e9667549970f2f209bfb11b51c36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
title: Conditionals
---
Allow the control of whether to execute instructions or not according to a
computation. Every conditional branch defines its hierarchy level, from the
local variables' point of view.

### IF
{{< fatecode >}}(if [BOOL]
   [INSTRUCTION]
){{< /fatecode >}}

Executes `[INSTRUCTION]` if, and only if, `[BOOL]` yields true.

### IF-ELSE
{{< fatecode >}}(if_else [BOOL]
   [IF_TRUE = INSTRUCTION]
   [IF_FALSE = INSTRUCTION]
){{< /fatecode >}}

Executes `[IF_TRUE]` if `[BOOL]` yields true, but `[IF_FALSE]` if it does not.

### COND
{{< fatecode >}}(cond
   ([C0 = BOOL] [I0 = INSTRUCTION])
   ...
   ([CN = BOOL] [IN = INSTRUCTION])
){{< /fatecode >}}

Executes `[II]`, such that `[CI]` is the first listed boolean to yield true.

### SWITCH
{{< fatecode >}}(switch [T = COMPUTATION]
   ([C0 = COMPUTATION] [I0 = INSTRUCTION])
   ...
   ([CN = COMPUTATION] [IN = INSTRUCTION])
   [DEFAULT = INSTRUCTION]
){{< /fatecode >}}

Executes `[II]`, such that `[CI]` is the first listed computation to be equal
to `[T]`. Executes `[DEFAULT]` if there is no such `[CI]`.