From bd4c0c8d9fd33b35a0c4d98ca2dd641e3fafbfd3 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 1 Oct 2024 10:36:59 -0700 Subject: Fix parsing forward ref arrays --- chapter15/README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'chapter15/README.md') 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 -- cgit v1.2.3