blob: 25725913e7df099cbf83c4625f8f6978d0a810d6 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# Union
---
```text
Union[CONTAINER | TRANSIENT | TRANSIENT_GENERIC] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
```
## Type Body Object Definitions
```c
typedef struct {
kpl_ptr var_tree, var_list;
} kpl_type_body_union;
```
# Alias
```text
Tag[Collection[VAR_TREE_LIST; TYPE.SYMBOL]] `alias Union[[CONTAINER] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
```
## Tag Example
```text
u : Tag[I64.a; I64.b; I64.c] $ (.c : 5)
# u {
.c {[c] c ... }
{ ... } // default
}
```
# Operators
## ``take`
# Transient Unions
Can only be retuned from functions and operations. The inner value must be moved out
## Alias
```text
Transient_generic[Generic.T] `alias Union[[TRANSIENT_GENERIC] Generic.T.value]
Result[Generic.T] `alias Union[[TRANSIENT] Generic.T.value; Error.error]
Option[Generic.T] `alias Union[[TRANSIENT] Generic.T.value; Void.null]
Next[Generic.T] `alias Union[[TRANSIENT] Generic.T.value; Void.done]
Next_result[Generic.T] `alias Union[[TRANSIENT] Generic.T.value; Error.error; Void.done]
Next_option[Generic.T] `alias Union[[TRANSIENT] Generic.T.value; Void.null; Void.done]
```
## Default Operation
When a transient union is assigned the first type specified is moved out.
If no match is used and if the type is not the first specified a result with an error is returned
```text
z : x / y // Result[...]
z // is value if y is not zero
```
## Operators
### \`value
### \`error
### \`null
|