summaryrefslogtreecommitdiff
path: root/chapter15/README.md
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2024-10-01 10:36:59 -0700
committerCliff Click <cliffc@acm.org>2024-10-06 08:56:22 -0700
commitbd4c0c8d9fd33b35a0c4d98ca2dd641e3fafbfd3 (patch)
tree9f3a191348482bc6942cb1f256d112059a122776 /chapter15/README.md
parente315432bbd1ffa4e2dd562c4f4fc454ea1ba2464 (diff)
downloadSimple-bd4c0c8d9fd33b35a0c4d98ca2dd641e3fafbfd3.tar.gz
Simple-bd4c0c8d9fd33b35a0c4d98ca2dd641e3fafbfd3.zip
Fix parsing forward ref arrays
Diffstat (limited to 'chapter15/README.md')
-rw-r--r--chapter15/README.md16
1 files changed, 9 insertions, 7 deletions
diff --git a/chapter15/README.md b/chapter15/README.md
index 50a0493b..354b6c66 100644
--- a/chapter15/README.md
+++ b/chapter15/README.md
@@ -14,12 +14,12 @@ Like Java, arrays are always safety checked, and failing a runtime check
will panic the Evaluator.
- Indexing out of bounds:
-- - `ary[-1]`
-- - `ary[ary#]`
+- `ary[-1]`
+- `ary[ary#]`
- Creating an array with a bad length:
-- - `new int[-1]; // Negative length`
-- - `new int[1<<63]; // Too large`
-- - `new int[3.14]; // Not an integer`
+- `new int[-1]; // Negative length`
+- `new int[1<<63]; // Too large`
+- `new int[3.14]; // Not an integer`
## Parser
@@ -33,8 +33,10 @@ Arrays are always created with zero/null bodies, so implicitly always allow
`null` values.
We make a new array with much the same syntax as making a new object: `new
-int[99][99]`. The length is required and is any integer expression, so
-e.g. `int[arg]` is an integer array of length `arg`.
+int[99]`. The length is required and is any integer expression, so
+e.g. `int[arg]` is an integer array of length `arg`. Multi-dimensional arrays
+only make the outer dimension; the elements themselves are all null and typed
+as the next lower dimension array.
Arrays implicitly have two fields: the length and the body. The length is a
read-only field set when the array is allocated; it is referenced with the