diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-07-09 16:14:23 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-07-09 16:14:23 +0200 |
commit | 674bce8c96309ae7c38a7e2b946f3f18430a0b00 (patch) | |
tree | 9a2b58ad0194493e1998211c08e6c82109309654 /README | |
parent | 1a769e8ef02893f737a88fe683add8ffea7affb1 (diff) |
Support static-local variables
Diffstat (limited to 'README')
-rw-r--r-- | README | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -168,3 +168,19 @@ The build script also accepts some subcommands. They are as follows: ((x)) = x*10 + y; /* legal */ (true ? x : y) = x*10 + y; /* illegal */ + +10. Static local variables allow for block-scoped global variables. This + is useful for having function state persist across multiple calls. + + iota :: () int { + static x := -1; + x = x + 1; + return x; + } + + pub main :: () { + zero := iota(); + one := iota(); + two := iota(); + three := iota(); + } |