Design decisions

6. Program structure

#DecisionStatusCurrent leanDepends onWhere
6.1File as function bodySettledtop-level fns see the body's lets; calling before the lets are set is an errorplan/15-program-structure.md §2
6.2Program vs library modeSettleddecided by contents; use accepts only librariesplan/15-program-structure.md §2.4
6.3MultitestRevised 2026-11-20 (0.2.2)@!multitest is a standalone top-level divider: statements above it run once (precomputation), statements below it run once per test case (the count is read automatically; @!multitest(until_eof) reads to end of input), each case in a fresh scope with @memo caches reset. Single-test and multitest files are both flat top-level statements; no fn solve() wrapper. @! marks a file-level directive in force from its line down; @ always decorates the one item below it. Top-level return ends the program, or the current test case below the divider. @spec / @checker read the top-level input lets the same way in both modes6.1§16, §19.3, §20
6.4Modules beyond pubOpenre-exports, private-to-folder, name clashesplan/40-tooling.md
6.5Parts and puritySettledany fn is a part; tools record I/O; no pure keywordplan/15-program-structure.md §4
6.6Brutes, checkers, interactorsRevised 2026-11-20 (v2.2)@brute, @checker (inherits input bindings, uses read_output() + assert), @interactor fn judge(sol: Interactor): (read() = hidden test, sol.recv() = sol stdout, sol.send(...) = sol stdin; paired with ask(..., limit: K), and print() auto-flushes whenever ask() is used)3.11§16, §19.8
6.7Staying under 64 KBLocked v2.2 (2026-11-20)Tree-shake all runtime/stdlib helpers and strip CP_GEN/debug/@brute in judge builds (target 4–10 KB typical, always < 64 KB)3.2§16, §19.1, research/perf/max-n-judge-audit-1.md
6.8Grader-style (IOI) problemsRevised 2026-11-20 (v2.2)@grader without new keywords: bodyless @grader fn = extern oracle (callable inside @memo), @grader fn with body = exported entry, top-level var or @grader struct = stateful grader; array params may size off sibling Int params left or right. @grader const and uninitialized file-scope grader domains deleted3.11, 6.1§16, §18.10, §19.3, §19.9
6.9Top-level varLocked v2 (2026-11-20)allowed; any nested fn declared after a var reads/writes it directly (5.10)5.10§16