Design decisions

97. Auto-loaded Bitset for domain subset ops, struct array scalar-fill defaults, range-alias dims, [0..n]?T = read(none:), and ?T.map/.filter (2026-11-21)

  • Decision.
    1. Add ("all", "Bitset") and ("without", "Bitset") to cpl_check::prelude::BUILT_ON (skipping stdlib/ paths to prevent stdlib cycles) so methods on values returned by prelude/domain members (for v in V.all.without(c)) work without importing std.bitset.{Bitset}.
    2. Allow scalar-fill broadcast (array_fills) on struct field defaults and function parameter defaults (count: [Vol]Int = 0, delta: [0..=n + 1]Z = 0), resolve Sym::Alias in Lowerer::dim so range aliases (type Vol = 1..=5) work as array dimensions, and lower typed let a: [0..n]?T = read(none: sentinel) through Spec + reads_none_as.
    3. Add ?T.map(f) and ?T.filter(p) across cpl-check and cpl-ir (accepting lambdas, functions, or arrays), lowering to Do/If/IsSome/Unwrap/Some/None with zero new backend ops.
  • Why. Mining the 39 under-4 dreams (Dream: [1-3]/5) showed struct-field array defaults (cf2066e, cf2124f2), range-indexed sentinel reads (cf2129d), and ?T.map/.filter (cf2124f2, wtf26d, cf2084g1, cf2084g2, cf2084h) were the top domain/type-system gaps, while V.all.without(c) required an explicit Bitset import even though the user never named Bitset.
  • Evidence. proto/ports/ecnerwala/dream/cf2129d.cp and cf2084g1.cp now pass cpl check with 0 errors; cf2084g1 port adopts at[k + 1].map(...) and passes gate.sh cf2084g1 5; existential_compress.cp and dream_gaps.cp pass differential interp + sanitized C++17 parity.
  • Reverse. Remove the two BUILT_ON entries in crates/cpl-check/src/prelude.rs, revert array_fills on defaults / Sym::Alias in Lowerer::dim / read_none_arg in crates/cpl-ir/src/lower/stmt.rs, and remove the Ty::Optional "map" | "filter" arms in crates/cpl-check/src/check/call.rs and crates/cpl-ir/src/lower/call.rs.