# Step 4 goal — Composite types (saved, to implement tomorrow) ## Scope (Phase 3 of the plan) - `ARRAY`: bounds, indexing (incl. multi-dimensional), scaled address arithmetic, indexed loads/stores (`0EH`/`1EH`), open-array parameters. - `RECORD`: field layout with offsets, `.field` selection, `WITH`. - `SET`: add operators (`+` union, `-` difference, `*` intersection); literals/`IN`/`=`/`#` already work since step 2. - `POINTER`: `NEW`/`DISPOSE`, dereference, `NIL` handling. - Strings: string variables as `ARRAY OF CHAR`. ## Design deltas (vs step 3) - SymTab: byte sizes on descriptors, field/element offsets, per-variable sizes (frame + globals); new queries (`TypeSize`, `FieldOffset`, …). - MGen: scaled indexing, `copy_block` for composite assignment. - Policy to fix at start: range checking (checked vs unchecked), `NIL` dereference (runtime trap, no static check). - `NEW` semantics: **recommended** — VM `ALLOCATE` (`0x40 05`), already implemented by the interpreter. Alternatives (e.g. compiler-managed bump region) to be decided if ALLOCATE misbehaves under test. ## Acceptance (same bar) ~15 run + ~10 rejection tests, all green, no cascades; full 49-test regression still passing (→ ~74 total). ## Suggested first tests Matrix multiply or sieve (arrays); nested records + `WITH`; set ops with ranges; linked list via `NEW`/`DISPOSE` (combines pointers with step-3 recursion). --- # Session checkpoint (saved, not committed) - Tags `step1`, `step2`, `step2.1`, `step3` exist locally (`step3` = `c0f1924`, suite 49/49 + mc64 24/24 green). - Pushing (commits + tags) is done by the user (credentials). - Uncommitted on disk: `summary_step1/2/2.1/3.md` (docs commit `0e07f06` was undone per user request), this `goal_step4.md`, plus pre-existing leftovers never touched (`m2comp/coco/` deletions, `gnu-m2-grammar.txt`, chatgpt folder, instructions file, `STAK`/`DEP.MC4`). - Next action: implement the step-4 goal above.