summary_wrap-modules.md 3.2 KB

Session summary — 2026-10-01 (d): wrapper/time library + showcase22

Suite 177/177; self-hosting fixpoint OK (image 2,899,706 bytes). Tag v3-wrap-modules.

This step added the gm2/ISO channel-and-time wrapper modules that the current dialect can express, plus a showcase touring them alongside the session's earlier work.

Steps, tags and headline commits

Step Tag Commit What
wrappers v3-wrap-modules 05d9bd0 StdChans, TimeString, wrapclock, wraptime, wrapc
Showcase + docs v3-wrap-modules (this commit) showcase22, this summary

(The same tag covers both, since the showcase is documentation of the step.)

1. Modules added

Module What
StdChans settable current channels (InChan/OutChan/ErrChan + setters) over IOChan; NullChan is a closed channel
TimeString GetTimeString — local time as strftime("%c")
wrapclock opaque timespec; timezone/istimezone/daylight/isdst/tzname; InitTimespec/KillTimespec, get/set fields, GetTimeRealtime/SetTimeRealtime
wraptime opaque timeval/timezone/tm; gettimeofday/settimeofday, GetFractions, LocalTime, field accessors, SetTimeval/SetTimezone
wrapc getrand, signbit/isfinite/isnan (f/l variants), SeekSet/SeekEnd, ReadOnly/WriteOnly, filesize/fileinode/filemtime, getusername, getnameuidgid, strtime

The shim gains m2timestring and underscore-free m2wc*/m2wt*/ m2c* helpers (classic Modula-2 identifiers have no _, so the helper names avoid it while the Modula-2-facing names match gm2).

2. Deliberate deviations

  • wrapc.ReadOnly/WriteOnly return CARDINAL, not BITSET: BITSET is not accepted as a function-result type in V3 (nor is VAL(BITSET, n)).
  • wraptime.localtime_r is spelled LocalTime — the _ is illegal in a classic identifier.

3. Not included

ChanConsts and StreamFile are written but not committed: their read = FlagSet{readFlag} constants need typed set constructors (T{lit}), which the frontend reports as not supported yet (untyped literals with an inferred base, b := {r, w}, do work). Both files remain on disk for the next step, which is a frontend change.

GenDevIF and DeviceTablePtr are not real gaps: they are not present in the installed gm2 library set.

4. Showcase

compiler/tests/showcase22.mod (Showcase22, exit 42) tours:

  • forward module-level variables — Bump uses total/done before their VAR declaration;
  • expression result suffixes — GetRec()^.a, GetArr()^[i];
  • the wrapper library — StdChans.OutChan, a wrapclock timespec roundtrip, a wraptime timeval+LocalTime, wrapc.getrand range and signbit/isfinite, and TimeString.

    showcase22 total=42
    

Tests (177, was 176)

New: wrapprog.mod (the five modules, exit 42) and Showcase22.

Resume

cd .../m2compiler-V3
./bootstrap/fixpoint.sh                       # FIXPOINT OK
cd compiler && ./build.sh && ./run_tests.sh   # 177/177

Remaining

ChanConsts + StreamFile (typed set constructors); GOTO/labels; generics; statement-context result suffixes; multiple inheritance (deliberate).