runtime mutable global state
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
Point :: struct {
|
||||
x i32
|
||||
}
|
||||
|
||||
counter int = 0
|
||||
ratio float = 1
|
||||
span range = 0..2
|
||||
point Point = Point { x = 1 }
|
||||
values [_]mut i32 = [10, 20]
|
||||
|
||||
bump func(value @mut i32) void {
|
||||
value^ += 1
|
||||
}
|
||||
|
||||
main func() i32 {
|
||||
counter = 10
|
||||
counter += 5
|
||||
bump(&counter)
|
||||
point.x += counter
|
||||
values[1] = point.x
|
||||
|
||||
total i32 = counter + point.x + values[1]
|
||||
for span |i| {
|
||||
total += i
|
||||
}
|
||||
if ratio == 1.0 {
|
||||
total += 1
|
||||
}
|
||||
return total
|
||||
}
|
||||
Reference in New Issue
Block a user