# PIM4 vs GNU Modula-2 vs V3 β€” feature comparison **Date:** 2026-10-22 Β· **V3 state:** `v3-proc-types` (suite 255/255, self-hosting fixpoint OK 3,935,235 bytes, corpus 503/612, 0 crashes). **Scope.** **PIM4** is Wirth's *Programming in Modula-2*, 4th edition (the language specification, not a compiler). **GNU Modula-2 (gm2)** is the GCC front end: its PIM and ISO modes plus the extensions common in its testsuite. **V3** is this compiler: a PIM/ISO subset plus the gm2 compatibility it deliberately chose. **Legend:** βœ… supported / standard Β· πŸ”„ partial or caveated Β· ❌ absent Β· ⚠️ non-standard extension Β· n/a not applicable. The tables describe the common/default behaviour; the exact flags and modes of gm2 can change individual cells. V3's deliberate deviations are listed at the end. ## Standards & dialect | Feature | PIM4 | GNU Modula-2 | V3 | |---|---|---|---| | PIM base language | βœ… (definition) | βœ… (PIM 2/3/4 modes) | βœ… (PIM/ISO subset) | | ISO 10514-1 base | ❌ (predates ISO) | βœ… | πŸ”„ mostly; see missing ISO rows below | | ISO 10514-2 generics | ❌ | βœ… | βœ… (refinement form) | | ISO 10514-3 OO | ❌ | ❌ | ❌ (`CLASS` is Clarion-form, not ISO OO) | | Declaration before use | βœ… strict | πŸ”„ multi-pass, accepts forward refs | βœ… strict for data; πŸ”„ forward **procedure** calls allowed | | `FORWARD` declarations | βœ… | βœ… | βœ… | | `EXPORT QUALIFIED` / `UNQUALIFIED` | ❌ (PIM export list only) | βœ… | βœ… | | Foreign modules (`DEFINITION MODULE FOR "C"`) | ❌ | βœ… | βœ… | ## Lexical | Feature | PIM4 | GNU Modula-2 | V3 | |---|---|---|---| | Identifiers with `_` | ❌ (classic names) | βœ… | βœ… | | Numeric bases | βœ… octal `B`, hex `H` | βœ… `B`/`H` (and more) | ❌ (`0x`/`0X` only; `012H`/`666B` rejected) | | Nested `(* *)` comments | βœ… | βœ… | βœ… | | `'…'` and `"…"` strings | βœ… | βœ… | βœ… | | Unicode `UCHAR`/`UString` | ❌ | ❌ | βœ… (extension: `U'a'`, `U"…"`, `UCHR`, `UORD`) | ## Types | Feature | PIM4 | GNU Modula-2 | V3 | |---|---|---|---| | `INTEGER`/`CARDINAL`/`SHORTINT`/`LONGINT`, `REAL`/`LONGREAL`, `BOOLEAN`, `CHAR` | βœ… | βœ… | βœ… | | Subranges | βœ… | βœ… | βœ… (typed CHAR/enum subranges since 2026-10-22) | | Enumerations | βœ… | βœ… | βœ… | | Sets (`SET OF`) | βœ… any finite ordinal (impl. limit) | βœ… | πŸ”„ bool/char/enum/small-int subrange; span ≀ 65536; no `SET OF CARDINAL` | | `PACKEDSET` | ❌ (ISO) | βœ… | ❌ | | Fixed arrays, multi-dimensional | βœ… `ARRAY [a], [b] OF` | βœ… | βœ… both `[a], [b]` and `[a, b]` | | Open arrays (1-D) | βœ… | βœ… | βœ… | | Multi-dimensional open arrays | ❌ (ISO addition) | βœ… | ❌ (V3 descriptor-per-level representation; `unbounded*` gaps) | | Records, variant records | βœ… | βœ… | βœ… (plus empty arms/`ELSE` extensions) | | Pointers, `NIL`, opaque types | βœ… | βœ… | βœ… | | Procedure types | βœ… (`PROCEDURE`) | βœ… (`PROCEDURE`, `PROC`) | βœ… (`PROCEDURE`, `PROC`; comma/unnamed forms) | | Complex types (`COMPLEX`, `LONGCOMPLEX`) | ❌ | βœ… (ISO) | ❌ (`COMPLEX64` is a `REAL` placeholder, no arithmetic) | | SYSTEM sized types (`WORD32`, `CARDINAL8`, `BITSET32`, …) | ❌ | βœ… | βœ… names, but mapped to V3's 32-bit/64-bit model | | `BYTE` granularity | βœ… 8-bit | βœ… 8-bit | πŸ”„ `BYTE` = 32-bit `CARDINAL`; `ARRAY OF BYTE` is not byte-granular | | `SHORTREAL` (32-bit) | ❌ | βœ… | ❌ (all reals are 8 bytes) | | `ADDRESS` arithmetic (`ADDADR`/`SUBADR`/`DIFADR`) | ❌ | βœ… | ❌ | | Absolute variables `VAR [addr]: T` | ❌ | βœ… (extension) | ❌ | | Set ordering (`<`, `<=`, `>`, `>=`) | ❌ (`=`/`#`/`IN` only) | βœ… (extension) | ❌ | ## Statements & procedures | Feature | PIM4 | GNU Modula-2 | V3 | |---|---|---|---| | `IF`/`CASE`/`WHILE`/`REPEAT`/`LOOP`/`EXIT`/`WITH`, `RETURN`, `HALT` | βœ… | βœ… | βœ… | | `FOR` over any ordinal (CHAR/enum) | βœ… | βœ… | βœ… (since 2026-10-22) | | `GOTO` / labels | βœ… | βœ… | βœ… | | `INC`/`DEC` on enumerations | ❌ (integer) | βœ… | ❌ (integer only) | | Empty string `""`/`''` as `CHAR` | ❌/unclear (ISO rule) | βœ… | βœ… (ISO rule, since 2026-10-22) | | `LENGTH` | ❌ (ISO adds it) | βœ… | βœ… | | `HIGH` | βœ… | βœ… | βœ… / πŸ”„ (`HIGH` of a string `CONST` still missing) | | `TSIZE`/`SIZE`/`ADR` | βœ… | βœ… | βœ… | | `SHIFT`/`ROTATE` | ⚠️ implementation SYSTEM extension | βœ… | βœ… | | `TBITSIZE` | ❌ | βœ… | ❌ | | ISO exceptions (`EXCEPT`, `RETRY`, `EXCEPTIONS`) | ❌ | βœ… | ❌ | | Module finalization (`FINALLY`) | ❌ | βœ… | ❌ | | `__FILE__` / `__LINE__` / `__FUNCTION__` | ❌ | βœ… | βœ… / βœ… / ❌ | | `__BUILTIN__` / `__ATTRIBUTE__` pragmas | ❌ | βœ… | βœ… (parsed, ignored) | | Inline `ASM` | ❌ | βœ… | ❌ | ## Modules, compilation, libraries | Feature | PIM4 | GNU Modula-2 | V3 | |---|---|---|---| | Definition / implementation / program modules | βœ… | βœ… | βœ… | | Local modules | βœ… | βœ… | βœ… | | Separate compilation | βœ… | βœ… (object files/archives) | πŸ”„ one invocation compiles all units into one image; no incremental objects | | Generics | ❌ | βœ… | βœ… | | Object orientation | ❌ | ❌ | πŸ”„ Clarion-form `CLASS` (single inheritance, virtual dispatch), not ISO 10514-3 | | PIM coroutines (`PROCESS`, `NEWPROCESS`, `TRANSFER`, `IOTRANSFER`) | βœ… | βœ… | βœ… (`IOTRANSFER` degrades to a transfer) | | ISO `COROUTINES` module | ❌ | βœ… | ❌ (PIM interface only) | | Standard library | ❌ (none defined) | βœ… PIM + ISO libraries | πŸ”„ subset: ISO/PIM I/O, strings, storage, SysClock; no ISO exceptions/termination libs | | Self-hosting | n/a | βœ… (part of GCC) | βœ… (byte-identical 3-stage fixpoint) | | Backend / target | n/a | GCC (many targets) | QBE β†’ C (amd64 SysV today) | ## The practical differences - **PIM4** is the clean specification: strict declaration order, no ISO exceptions/complex numbers/`PACKEDSET`/generics, no standard library, no sized SYSTEM types or address arithmetic. - **gm2** is the superset in practice: PIM and ISO modes, generics, exceptions, complex numbers, `PACKEDSET`, multi-dimensional open arrays, sized SYSTEM types, address arithmetic, absolute variables, `ASM`, pragmas, and many extensions β€” but deliberately permissive (multi-pass resolution accepts forward references). - **V3** is a PIM/ISO compiler with the opposite bias: it rejects gm2 leniencies (declaration order), implements the common ISO/PIM constructs (generics, coroutines, foreign modules, ISO strings/SYSTEM/ procedure types, empty string as `CHAR`), and documents its chosen gm2 compatibility (`__FILE__`/`__LINE__`, scalarβ†’`ARRAY OF BYTE`, same-size `VAR`, bare proc values, variant extensions, set `CASE` labels, libc prototypes). Its hard gaps are the large ISO features (**exceptions, complex arithmetic, `PACKEDSET`, finalization/protection, multi-dimensional open arrays, ISO OO**) and its **32-bit word model** (`BYTE` granularity, `SHORTREAL`, `REAL` width), plus a **65536-bit set span limit**. ## V3-specific deviations and limits - **Strict data declaration order** (PIM-conforming); forward **procedure** calls are allowed where strict PIM would require `FORWARD`. - **32-bit word model:** `INTEGER`/`CARDINAL`/`WORD`/`BYTE` are 32-bit; `LONGINT`/`LONGCARD` are 64-bit; every `REAL`/`SHORTREAL` is 8 bytes; `COMPLEX*` is a placeholder. `ARRAY OF BYTE` is a compatibility descriptor, not an 8-bit buffer. - **Sets:** bases limited to bool/char/enum/small subranges; total span ≀ 65536; no `SET OF CARDINAL`. - **No runtime range checks** on subrange assignment (V3 is already lenient for the integer family). - **Multi-dimensional open arrays** are not supported: V3 represents an array level as its own descriptor, whereas gm2 passes a flat block β€” accepting the corpus files would compile but miscompile. - **Single-invocation compilation:** definition, implementation and program units are compiled together into one image; there is no incremental object/archive format. - **OO** is the Clarion-form `CLASS` dialect (single inheritance, virtual dispatch), not ISO 10514-3. ## Sources - V3: `docs/STATUS.md`, `docs/features.md`, `docs/gaps/README.md`, `docs/analysis_gaps.md`, `docs/summary_session-2026-10-22.md`; the gates in this document were run at `v3-proc-types`. - gm2: the GCC Modula-2 testsuite and `gm2-libs`/`gm2-libs-iso` definition modules in the sibling `gcc-git` tree. - PIM4: N. Wirth, *Programming in Modula-2*, 4th edition.