1 |
|
2 | # We can provide a shortcut:
|
3 |
|
4 | # export mutate-g1 mutateG2
|
5 | # export --funcs --procs # for convenience
|
6 |
|
7 | const __provide__ = :| mutate-g1 mutateG2 |
|
8 |
|
9 | var g1 = 'g1'
|
10 | var g2 = 'g2'
|
11 |
|
12 | var d = {g: 1}
|
13 | #pp test_ ([id(d), d])
|
14 |
|
15 | proc mutate-g1 {
|
16 | echo "g1 = $g1"
|
17 | setglobal g1 = 'proc mutated'
|
18 | echo "g1 = $g1"
|
19 |
|
20 | setglobal d = {'proc mutated': 42}
|
21 |
|
22 | #pp test_ ([id(d), d])
|
23 | }
|
24 |
|
25 | # Should we disallow setglobal in func? Yes I think so
|
26 | func mutateG2() {
|
27 | echo "g2 = $g2"
|
28 | setglobal g2 = 'func mutated'
|
29 | echo "g2 = $g2"
|
30 | }
|
31 |
|
32 | #pp frame_vars_
|
33 |
|
34 | #mutate-g1
|
35 | #call mutateG2()
|
36 |
|