From 684f59c48cb865ecf935be47d6f59e94f1e77961 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Wed, 27 May 2026 02:03:04 +0900 Subject: [PATCH] lib/strconv: decimal.ww header documents i_sz/lowbit_lit hoist sub-cases (#32 c2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a sub-bullet to the 8-spelling-divergences list documenting two implementation sub-cases reviewer-fold3 surfaced during the 07e57ff decimal.ha port: (1) `i_sz` per-iteration size-cast hoist inside leftshift_newdigits' for-loop (decimal.ww:93); (2) `lowbit_lit` stepwise boolean decomposition in should_round_up (decimal.ww:242) dodging ww parser precedence on Hare's `(nd > 0 && d.digits[nd - 1] & 1 != 0)` (ref/hare/strconv/decimal.ha:158). Both are in-file instances of the documented hoist+restructure patterns — rule-9 doc-completeness, not new divergence. Combined.ww regen for lib/strconv (compiler-imported into w6c + wwdump + smoke) uses the build's include paths (`-I lib/ww -I lib/ww/lex -I lib/ww/parse -I selfhost/cmd/wcc`) for transitive import closure; bare `ww build` without these flags produces truncated output (reviewer-32c2 + reviewer-fold3 both hit this). --- lib/strconv/decimal.ww | 7 +++++++ selfhost/cmd/w6c/main.combined.ww | 7 +++++++ selfhost/cmd/wwdump/main.combined.ww | 7 +++++++ selfhost/test/smoke.combined.ww | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/lib/strconv/decimal.ww b/lib/strconv/decimal.ww index a70babc9..c89fccf0 100644 --- a/lib/strconv/decimal.ww +++ b/lib/strconv/decimal.ww @@ -24,6 +24,13 @@ // → ww requires a `{}` block body throughout. // - Hare bare `assert(cond)` builtin → `os.assert(cond, msg)`; // wwstage cgen has no `assert` intercept (deferred fold). +// - In-file instances of the above hoist pattern: `i_sz` (line 93) +// hoists a per-iteration size cast out of a for-loop comparison +// (bullet 3 sub-case — the size-cast hoist applied inside a loop +// body, not just at function entry); `lowbit_lit` (line 242) +// decomposes Hare's `(nd > 0 && d.digits[nd - 1] & 1 != 0)` into +// a stepwise boolean local to dodge ww parser precedence on mixed +// `&` / `&&` / `!=` within a single expression. // // CGEN class closures consumed (post-prereqs): // - #131 (4acab6e) — `len(d.digits)` compile-time-folds cs==ww diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index b38703c8..4616c501 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -2730,6 +2730,13 @@ export fn rpad(s: str, p: rune, maxlen: i32) str = { // → ww requires a `{}` block body throughout. // - Hare bare `assert(cond)` builtin → `os.assert(cond, msg)`; // wwstage cgen has no `assert` intercept (deferred fold). +// - In-file instances of the above hoist pattern: `i_sz` (line 93) +// hoists a per-iteration size cast out of a for-loop comparison +// (bullet 3 sub-case — the size-cast hoist applied inside a loop +// body, not just at function entry); `lowbit_lit` (line 242) +// decomposes Hare's `(nd > 0 && d.digits[nd - 1] & 1 != 0)` into +// a stepwise boolean local to dodge ww parser precedence on mixed +// `&` / `&&` / `!=` within a single expression. // // CGEN class closures consumed (post-prereqs): // - #131 (4acab6e) — `len(d.digits)` compile-time-folds cs==ww diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index a5714279..42eced79 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -753,6 +753,13 @@ export fn exists(path: str) bool = { // → ww requires a `{}` block body throughout. // - Hare bare `assert(cond)` builtin → `os.assert(cond, msg)`; // wwstage cgen has no `assert` intercept (deferred fold). +// - In-file instances of the above hoist pattern: `i_sz` (line 93) +// hoists a per-iteration size cast out of a for-loop comparison +// (bullet 3 sub-case — the size-cast hoist applied inside a loop +// body, not just at function entry); `lowbit_lit` (line 242) +// decomposes Hare's `(nd > 0 && d.digits[nd - 1] & 1 != 0)` into +// a stepwise boolean local to dodge ww parser precedence on mixed +// `&` / `&&` / `!=` within a single expression. // // CGEN class closures consumed (post-prereqs): // - #131 (4acab6e) — `len(d.digits)` compile-time-folds cs==ww diff --git a/selfhost/test/smoke.combined.ww b/selfhost/test/smoke.combined.ww index 3c8763e6..ed340db3 100644 --- a/selfhost/test/smoke.combined.ww +++ b/selfhost/test/smoke.combined.ww @@ -753,6 +753,13 @@ export fn exists(path: str) bool = { // → ww requires a `{}` block body throughout. // - Hare bare `assert(cond)` builtin → `os.assert(cond, msg)`; // wwstage cgen has no `assert` intercept (deferred fold). +// - In-file instances of the above hoist pattern: `i_sz` (line 93) +// hoists a per-iteration size cast out of a for-loop comparison +// (bullet 3 sub-case — the size-cast hoist applied inside a loop +// body, not just at function entry); `lowbit_lit` (line 242) +// decomposes Hare's `(nd > 0 && d.digits[nd - 1] & 1 != 0)` into +// a stepwise boolean local to dodge ww parser precedence on mixed +// `&` / `&&` / `!=` within a single expression. // // CGEN class closures consumed (post-prereqs): // - #131 (4acab6e) — `len(d.digits)` compile-time-folds cs==ww