summaryrefslogtreecommitdiff
path: root/chapter17/README.md
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2024-11-15 12:32:44 -0800
committerCliff Click <cliffc@acm.org>2024-11-23 09:03:20 -0800
commitc3e2f0a9997b867291cc4a3611c2acf7aeff2310 (patch)
treeed96bbf3ab3a6217c860bb7dd5ae1c5f071fbdb3 /chapter17/README.md
parent9c384ff44d32857b81723c82aeea0bcbd8aab30c (diff)
downloadSimple-c3e2f0a9997b867291cc4a3611c2acf7aeff2310.tar.gz
Simple-c3e2f0a9997b867291cc4a3611c2acf7aeff2310.zip
Update README.md
Diffstat (limited to 'chapter17/README.md')
-rw-r--r--chapter17/README.md13
1 files changed, 7 insertions, 6 deletions
diff --git a/chapter17/README.md b/chapter17/README.md
index e37fa9b7..d639962e 100644
--- a/chapter17/README.md
+++ b/chapter17/README.md
@@ -10,6 +10,8 @@ as `(arg--)-arg`.
Also allows `s.fld++` and `ary[idx]++`, and their `--` variants.
Allow pre-increment for identifiers only, for now: `--pc`.
+`--ary[idx]` `ary[idx] -= 1`
+`--expr.fld`
## Operator assignment
@@ -41,8 +43,8 @@ infers as
## Mutability
Typed primitive fields are always mutable. Typed reference fields without an
-initializer must be mutable to get a value. References with an initializer are
-immutable by default and can be made mutable with a leading `!`. `var` and
+initializer must be mutable to get a value. Initialized reference variables
+are immutable by default and can be made mutable with a leading `!`. `var` and
`val` keep their current sense and can be used to make any field mutable or
immutable. Fields are always mutable during construction, but will become
immutable at the end of either constructor.
@@ -73,10 +75,9 @@ through other references.
### References with an initializer are deeply immutable
-References with an initializer are deeply immutable, but a mutable version of
-the same reference can exist. This works for `var` and normal type
-declarations: `var s = new S;` and `S s = new S` both make `s` an
-immutable reference to a `struct S`.
+Initialized variables are deeply immutable, but a mutable version of the same
+reference can exist. This works for `val` and normal type declarations: `val s
+= new S;` and `S s = new S` both make `s` an immutable reference to a `struct S`.
```cpp
struct Bar { int x; }