2021-08-24 19:20:23 +03:00
|
|
|
A short script to test mutable references with local scope.
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2021-08-24 19:20:23 +03:00
|
|
|
test = Scope.run 'let
|
|
|
|
r = Scope.ref 0
|
|
|
|
Ref.write r 1
|
|
|
|
i = Ref.read r
|
|
|
|
Ref.write r 2
|
|
|
|
j = Ref.read r
|
|
|
|
Ref.write r 5
|
|
|
|
(i, j, Ref.read r)
|
|
|
|
|
|
|
|
> test
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2021-08-24 19:20:23 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2021-08-24 19:20:23 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
|
|
|
test : (Nat, Nat, Nat)
|
|
|
|
|
|
|
|
Now evaluating any watch expressions (lines starting with
|
|
|
|
`>`)... Ctrl+C cancels.
|
|
|
|
|
|
|
|
10 | > test
|
|
|
|
⧩
|
|
|
|
(1, 2, 5)
|
|
|
|
|
|
|
|
```
|