aboutsummaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-07-09 16:14:23 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-07-09 16:14:23 +0200
commit674bce8c96309ae7c38a7e2b946f3f18430a0b00 (patch)
tree9a2b58ad0194493e1998211c08e6c82109309654 /README
parent1a769e8ef02893f737a88fe683add8ffea7affb1 (diff)
Support static-local variables
Diffstat (limited to 'README')
-rw-r--r--README16
1 files changed, 16 insertions, 0 deletions
diff --git a/README b/README
index a8f0b7c..f30fdb1 100644
--- a/README
+++ b/README
@@ -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();
+ }