summaryrefslogtreecommitdiff
path: root/docs/language/ownership.md
blob: 2c5de36278b13255943de4c6864fbe2c2493c316 (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
# Ownership

---

# Copying

## Assignment

# Moving

## Assignment is not allowed for movable types that are not shared

## To And From Functions

# Passing

## References

References are automatically taken if the function signature specifies ref

```text
inc_push_to_ref : ([%ref x; y]
    x `push y + 1
)
int_array : Array[I64] $ ()
float_array : Array[F64] $ ()
@ 0 .. 2 {[x]
    inc_push_to_ref `sync (int_array, x)
    inc_push_to_ref `sync (float_array, F64 $ x)
}
`log int_array // Array[I64] $ (1; 2; 3)
`log float_array // Array[F64] $ (1.0; 2.0; 3.0)
```

#### Functions that take references cannot be called with ``async`

# Shared Types

# Locking

Prevent modification until a mutation occurs

## References

# Mutating

Unlock a lock or shared target and prevents modification to everything except the lock target