summaryrefslogtreecommitdiff
path: root/docs/type_system/shared.md
blob: d1d3f078940f3db19f8c941c80994f4475cf3430 (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
# Shared

---

Hold multiple references to the same object

```text
Shared[[] Type]
```

# Garbage Collection

A tracing mark and sweep garbage collector is used

# Mutating

```text
x : Shared[Array] $ (1; 2; 3)
^ x {[y]
    y `push 4
}
`log x // Shared[Array[I64]] $ (1; 2; 3; 4)
```

# Operators

## ``get`

## ``set`

### Example sharing data between two shared objects

```text
x : Shared $ 1
y : Shared $ 0

z : ^ x {[x] x }
^ y {[y] y : z }
// same as above
y `set `get x
```