lib: banner purge + WHY-only comment sweep (rule 8)

Every // ---- section banner dies (132 -> 0): names carry the WHAT.
Narration deleted (filename restatements, run-with lines, what-the-
next-line-does); every ref/hare cite, task cite, divergence, ABI/
layout contract, and ownership qualifier kept (borrowed-view lines
restored where the sweep over-cut). Comment-only proven: all 442
walk-workdir .s and 32 import-probe .s byte-identical before/after;
libbyteid 56-roster all-ID.
This commit is contained in:
2026-08-08 21:10:18 +09:00
parent 659e859f34
commit aadc6618f0
90 changed files with 259 additions and 919 deletions

View File

@@ -1,23 +1,6 @@
// fmt — formatting writers. Mirrors Hare's lib/fmt subset. Project #94
// fold-eFinal; io fold-2 (#5) graduated the sink to [[io.handle]].
//
// fprint / fprintln / fprintf / fprintfln
// write to an [[io.handle]] (= `(io.file |
// io.stream)`) — Hare's primary surface
// (ref/hare/fmt/print.ha:13). Errors via
// [[io.error]]. A file handle (raw fd) and a stream
// (`*io.vtable`) both flow in; [[io.write]]
// dispatches per arm.
//
// The process-stdio wrappers (print/println/errorln/printf/printfln/
// errorfln/fatal/fatalf) route through the fprint family over a file
// handle built from os.STD{OUT,ERR}_FILENO. The #5 handle convergence
// retired the prior `fd_ctx` shim — the fake-stream vtable around
// os.write that stood in before io.write took a handle.
//
// Call sites take Hare's variadic shape: `fmt.println(42, "hi", true)`
// gathers the args into a `[]formattable` slice; wrappers forward via
// `args...`.
// fmt — formatting writers. Mirrors Hare's lib/fmt subset (primary
// surface ref/hare/fmt/print.ha:13). Project #94 fold-eFinal; io
// fold-2 (#5) graduated the sink to [[io.handle]].
package fmt;
@@ -90,11 +73,6 @@ fn i64dec(v: i64) str = {
// construction — both stages now accept bare int by MEMBERSHIP.
export type formattable = (i64 | str | bool | rune | f64 | int | uint);
// ---- internal stream formatters --------------------------------------
// putbytes — io.write(s, [ptr..ptr+n)). Internal helper; the inline
// `let v` slice synthesis composes the (ptr, len) triple each
// formattable arm carries.
fn putbytes(s: io.handle, p: *u8, n: i32) (size | io.error) = {
let v: []u8;
v.ptr = p;
@@ -102,7 +80,6 @@ fn putbytes(s: io.handle, p: *u8, n: i32) (size | io.error) = {
return io.write(s, v);
};
// writeone — emit one formattable through io.write.
fn writeone(s: io.handle, a: formattable) (size | io.error) = {
match (a) {
case let n: i64 => {
@@ -145,8 +122,6 @@ fn writeone(s: io.handle, a: formattable) (size | io.error) = {
return 0: size;
};
// ---- {n}-placeholder parser -----------------------------------------
//
// Mirrors ref/hare/fmt/{iter,print,wrappers}.ha. Format sequences:
//
// {} implicit-positional next arg
@@ -636,8 +611,6 @@ fn formatfield(s: io.handle, f: field, m: *mods) (size | io.error) = {
};
};
// ---- stream sinks ----------------------------------------------------
// fprint — write the formatted form of each `args` element to `s`,
// separated by spaces. Returns total bytes written or the first
// io.error. Mirrors ref/hare/fmt/print.ha (fprint) + wrappers.ha.
@@ -818,9 +791,7 @@ export fn asprintf(fmt: str, args: field...) str = {
return strings.frombytes(tight);
};
// ---- process-stdio wrappers -----------------------------------------
//
// Mirror ref/hare/fmt/wrappers.ha. Hare routes these through
// Mirror ref/hare/fmt/wrappers.ha. Hare routes the stdio wrappers through
// os::stdout / os::stderr (io::handle); ww's os plays the sys role and
// can't import io (import floor), so it exports the std fd NUMBERS
// (os.STD{OUT,ERR}_FILENO) and the io.file binding is cast at the call

View File

@@ -1,6 +1,3 @@
// fmttest — exercises lib/fmt's stream sinks (fprint / fprintln).
// Run with `out/bin/ww run lib/fmt/fmttest.ww`.
//
// Each @test writes through a memio.stream and compares the resulting
// bytes against an inline `want` literal. Bodies are short enough that
// the parallel-array idiom used by memiotest doesn't apply — every row
@@ -24,10 +21,6 @@ fn streq(a: str, b: str) bool = {
return true;
};
// ---- an error-returning stream for the io.error surfacing test --------
//
// Replaces the OLD io.closed source. errvt is module-static; its
// reader/writer return a nomem-widened io.error.
let errvt: io.vtable;
fn errread(s: io.stream, buf: []u8) (size | io.eof | io.error) = {
@@ -42,8 +35,6 @@ fn errsource() io.stream = {
return &errvt;
};
// ---- fprint: bare str --------------------------------------------------
@test fn fprintbarestr() void = {
let mem: memio.stream = memio.dynamic();
let s: io.stream = &mem.vt;
@@ -59,8 +50,6 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprint: int + str mix, space-separated ----------------------------
@test fn fprintintstr() void = {
let mem: memio.stream = memio.dynamic();
let s: io.stream = &mem.vt;
@@ -76,8 +65,7 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprint: i64::MIN / int MIN whole-magnitude (#67) ------------------
// i64dec used `n = -n` within i64, which wraps at i64::MIN (-MIN == MIN),
// #67: i64dec used `n = -n` within i64, which wraps at i64::MIN (-MIN == MIN),
// so the digit loop never ran and only the bare '-' was emitted. The fix
// takes the magnitude through math.absi64 into u64. These rows pin the
// boundary value plus a normal negative, zero, and int MIN.
@@ -114,8 +102,6 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprint: bool + rune renders as "true A" --------------------------
@test fn fprintboolrune() void = {
let mem: memio.stream = memio.dynamic();
let s: io.stream = &mem.vt;
@@ -131,8 +117,6 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprint: zero args returns 0, no bytes written --------------------
@test fn fprintempty() void = {
let mem: memio.stream = memio.dynamic();
let s: io.stream = &mem.vt;
@@ -148,8 +132,6 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprintln: multi-arg, trailing '\n' --------------------------------
@test fn fprintlnmulti() void = {
let mem: memio.stream = memio.dynamic();
let s: io.stream = &mem.vt;
@@ -165,8 +147,6 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprintln: zero args writes just the newline ----------------------
@test fn fprintlnempty() void = {
let mem: memio.stream = memio.dynamic();
let s: io.stream = &mem.vt;
@@ -182,7 +162,6 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprint over a fixed stream: short writes return partial count ----
// memio.fixedwrite caps each call at the remaining buffer space and
// never closes the stream, so fprint sees a short i32 result, not
// io.error. Verifies the inner-loop arithmetic adds the actual byte
@@ -204,7 +183,6 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprint over a closed stream surfaces io.error -------------------
// Exercises the early-return arm in fprint's inner match — distinct from
// the short-write path above, which keeps returning i32 from a partial
// accept. Single arm is enough: every formattable case routes errors
@@ -220,10 +198,7 @@ fn errsource() io.stream = {
};
};
// ---- fprintf scenarios -------------------------------------------------
// Each scenario writes through memio.dynamic and compares bytes against
// an inline `want`. Variadic call-site shape forces one body per shape;
// see the file header.
// Variadic call-site shape forces one body per shape; see the file header.
@test fn fprintf_implicit() void = {
let mem: memio.stream = memio.dynamic();
@@ -303,8 +278,7 @@ fn errsource() io.stream = {
match (c) { case void => {}; case let eioe: io.error => abort(); };
};
// ---- fprint: rune args emit full UTF-8, not a truncated byte (#66) -----
// writeone/formatraw's rune arm did `buf[0] = r: u8; putbytes(...,1)`,
// #66: writeone/formatraw's rune arm did `buf[0] = r: u8; putbytes(...,1)`,
// emitting only the low byte (invalid UTF-8 for r > 0x7F). The fix routes
// through utf8.encoderune (ref/hare/fmt/print.ha:84). Edge runes: é (2B),
// € (3B), 😀 (4B), A (1B).
@@ -558,8 +532,6 @@ fn errsource() io.stream = {
os.free(r.ptr: *void, r.len: u64);
};
// ---- f64 dispatch arm -------------------------------------------------
//
// Pins the f64 formattable arm landed under task #17 (unblocked by #30
// — the variant-widen-from-X0 fix). strconv.f64tos drives the render;
// see lib/strconv/strconv.ww for the documented subset (fixed-point,