From b5ad5c2a2959d88327ee15e887b3c083c536c44a Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Fri, 15 Nov 2024 12:37:18 -0800 Subject: Fix spacing readme --- chapter17/README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'chapter17') diff --git a/chapter17/README.md b/chapter17/README.md index d639962e..462a67f5 100644 --- a/chapter17/README.md +++ b/chapter17/README.md @@ -10,8 +10,6 @@ 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 @@ -50,25 +48,33 @@ immutable. Fields are always mutable during construction, but will become immutable at the end of either constructor. `int x; x=3; x++; // OK, primitive so mutable` + `int x =3; x++; // Ok, primitive so mutable, despite initializer` Assume in the next examples this struct exists: `struct S { int x; };` Then: + `S s; s = new S ; s.x++; // OK, no initializer so s.x is mutable` + `S s; s = new S{x=3}; s.x++; // OK, no initializer so s.x is mutable` + `S s = new S ; s.x++; // Error, initializer so s.x is immutable` + `S s = new S{x=3}; s.x++; // Error, initializer so s.x is immutable` Leading `!` makes mutable: + `S !s = new S; s.x++; // Ok, has '!' so mutable` 'var' is variable: + `var s = new S; s.x++; // Ok, has var so mutable` 'val' is a "value": not mutable through this reference, but may be mutable through other references. + `val s = new S; s.x++; // Error, val so s.x is immutable` @@ -128,7 +134,3 @@ for( int i=0; i