blob: 8f39a6e4c82cfed09c8f5d65beae46aa5dd6327d (
plain) (
blame)
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
|
x: int;
/* You can define static local variables and use them */
foo :: () {
static bar := 42;
static baz: f32;
bar = bar * 2;
}
/* Static locals can shadow other globals */
bar :: () u128 {
static x: u128 = 1'000;
return x;
}
/* Shadowing works in nested functions */
baz :: () u128 {
static x: u128 = 1'000;
static y := 42;
nested :: () {
static x: i16;
x = 16;
}
return x;
}
|