diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-07-01 19:58:46 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-07-01 19:58:46 +0200 |
commit | 0543c146ad5904e3f7ad5a6208e9f30f72f47ca5 (patch) | |
tree | 7a714c6206a99eb469794e3ff0f12bfe85719dcb /README | |
parent | 4a95caabf15db0beeaceea09d1fb4b0964b119c9 (diff) |
Support assignments to mutable variables
Diffstat (limited to 'README')
-rw-r--r-- | README | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -149,3 +149,22 @@ The build script also accepts some subcommands. They are as follows: returns_42′ :: () int { return --x; } + +9. Assignment statements (not expressions). Unlike in C, you cannot put + an assignment inside of an expression. + + return_42 :: () int { + x := 4; + y := 2; + x = x*10 + y; + return x; + } + + Due to quirks of the language grammar identifiers may be wrapped in + (arbitrary levels of) parenthesis, however assignments are only + permitted if the left-hand side with parenthesis removed is a lone + identifier. The rationale behind this is to allow in the future + assignments to expressions that return pointers. + + ((x)) = x*10 + y; /* legal */ + (true ? x : y) = x*10 + y; /* illegal */ |