|
|
@@ -1,15 +1,16 @@
|
|
|
# Session summary — 2026-10-16 (c): generics increment 3
|
|
|
|
|
|
-Branch **`resolve-check`**, tree clean. Suite **211/211**; fixpoint
|
|
|
-**OK (3,702,885 bytes)**; corpus **372 OK / 0 crash**.
|
|
|
+Branch **`resolve-check`**, tree clean. Suite **213/213**; fixpoint
|
|
|
+**OK (3,706,134 bytes)**; corpus **372 OK / 0 crash**.
|
|
|
|
|
|
Tags: `v3-generics-value-params`, `v3-generics-inc3`,
|
|
|
-`v3-generics-proc-params`.
|
|
|
+`v3-generics-proc-params`, `v3-generics-constraints`.
|
|
|
|
|
|
## What inc3 added
|
|
|
|
|
|
ISO 10514-2 refinement generics now accept **value** and **procedure**
|
|
|
-parameters, plus **actual-kind constraints**.
|
|
|
+parameters, an **explicit constraint model**, and **actual-kind
|
|
|
+constraints**.
|
|
|
|
|
|
### 1. Value (constant) parameters
|
|
|
|
|
|
@@ -64,17 +65,38 @@ Refinement forms also accept `{ Import }` now. Verified end-to-end
|
|
|
(`Smaller(7,3)` through `IntSort`, `IntCompare` in a separate module,
|
|
|
returns 3).
|
|
|
|
|
|
+## 4. Constraint model
|
|
|
+
|
|
|
+A type formal may carry an explicit constraint:
|
|
|
+
|
|
|
+```modula2
|
|
|
+GENERIC DEFINITION MODULE OrdBox (T : TYPE (ORDINAL));
|
|
|
+TYPE Box = ARRAY [0..3] OF T;
|
|
|
+END OrdBox.
|
|
|
+DEFINITION MODULE IntBox = OrdBox(INTEGER); (* ok *)
|
|
|
+DEFINITION MODULE RealBox = OrdBox(REAL); (* rejected: 233 *)
|
|
|
+```
|
|
|
+
|
|
|
+`GenericFormal`'s `TYPE` branch takes an optional `( name )`;
|
|
|
+`ConsCode` maps `ORDINAL`/`INTEGER`/`REAL` → 0/1/2/3 and `ConsOk`
|
|
|
+tests the actual (`ORDINAL` → `SymTab.IsOrdinal`; `INTEGER` → `ClInt`;
|
|
|
+`REAL` → `ClReal`). The constraint is read from the formal's source on
|
|
|
+**both** passes (template and re-parse), so no extra state is needed.
|
|
|
+Verified: `OrdBox(INTEGER)` compiles and runs (`b[0]+b[3]` → 42);
|
|
|
+`OrdBox(REAL)` is rejected.
|
|
|
+
|
|
|
## Verification
|
|
|
|
|
|
-- Suite **211/211** (`BufProg`, `g_badbuf`, `SortProg`); forward tests,
|
|
|
- two-phase gates, and exit-code gates all green.
|
|
|
-- Fixpoint **OK** (3,702,885 bytes).
|
|
|
+- Suite **213/213** (`BufProg`, `g_badbuf`, `SortProg`, `OrdProg`,
|
|
|
+ `g_realbox`); forward tests, two-phase gates, and exit-code gates all
|
|
|
+ green.
|
|
|
+- Fixpoint **OK** (3,706,134 bytes).
|
|
|
- Corpus unchanged: **372 OK, 0 crash** (generics are not in the corpus).
|
|
|
|
|
|
## Remaining in the generics thread
|
|
|
|
|
|
-- A **richer constraint model** (e.g. "`T` must be ordinal") — next.
|
|
|
-- `GENERIC CLASS`; instance dedup; nested generics as actuals.
|
|
|
+- `GENERIC CLASS`; instance dedup; nested generics as actuals; further
|
|
|
+ constraint names (`POINTER`, `SCALAR`).
|
|
|
|
|
|
## Resume
|
|
|
|
|
|
@@ -84,4 +106,6 @@ cd .../m2compiler-V3/compiler
|
|
|
tests/g_isort.def tests/g_isort.mod tests/g_sortprog.mod # SortProg -> 3
|
|
|
./M2 tests/g_buf.def tests/g_buf.mod tests/g_buf10.def \
|
|
|
tests/g_buf10.mod tests/g_bufprog.mod # BufProg -> 42
|
|
|
+./M2 tests/g_ordbox.def tests/g_ordbox.mod tests/g_intbox.def \
|
|
|
+ tests/g_intbox.mod tests/g_ordprog.mod # OrdProg -> 42
|
|
|
```
|