aboutsummaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
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();
+ }