Files
AILang/examples/fieldtest/remove-mut_1_sum_of_squares.ail
T
Brummel 5bb721178f fieldtest: remove-mut-var-assign — 4 examples, all working; milestone CLOSED
Post-audit downstream-LLM-author field test of the post-removal
Form-A surface. 4 fresh real-world programs written from DESIGN.md +
form_a.md + public examples only (no compiler source): running
sum-of-squares accumulator (loop/recur → 385), grade cascade
(let-threaded if → 4/2/0), Horner polynomial straight-line build-up
(let-shadow chain → 73), multi-state bracket scanner threading
(rest,depth,ok) by tail recursion → true/false. 0 bugs, 0 friction,
0 spec_gap, 4 working — every task clean and correct on the first
try with only let/if/loop/recur; all parse|render|parse
byte-identical; zero mut/var/assign tokens produced (a doc-faithful
author did not reach for the removed construct).

The closest-to-friction case (multi-state machine restates the full
state tuple per tail-call) is correctly classified working, not a
spec_gap: that explicit-dataflow cost is the local-reasoning pillar
working as designed; mut's implicit cross-iteration persistence is
exactly the failure class the removal eliminates. mut-keyword
rejection is fail-closed with a diagnostic that enumerates the
surviving forms (no tombstone, no-nostalgia, as spec'd).

Removal thesis empirically CONFIRMED — mut was redundant with
let/if/loop/recur in 100% of the fresh tasks. The
remove-mut-var-assign milestone is fully ratified and CLOSED:
spec+plan+iter, audit clean (architect [high] form_a.md fixed in
.tidy, bench causally exonerated), fieldtest clean. Roadmap P0
flipped [~]→[x]; WhatsNew user-facing entry appended.
2026-05-18 11:28:34 +02:00

30 lines
885 B
Plaintext

; Axis: running numeric accumulator over a bounded range.
;
; Imperative instinct (the shape `mut` would invite):
; s = 0
; for i in 1..=n: s = s + i*i
; return s
;
; Surviving-surface shape: a `loop` with two binders (i counter,
; acc accumulator) and a `recur` in the tail of the else branch.
; sum_sq(10) = 1+4+9+16+25+36+49+64+81+100 = 385.
; Expected stdout: 385
(module remove-mut_1_sum_of_squares
(fn sum_sq
(doc "Sum of i*i for i in 1..=n via loop/recur. Two binders: i (counter), acc (running total).")
(type (fn-type (params (con Int)) (ret (con Int))))
(params n)
(body
(loop (i (con Int) 1) (acc (con Int) 0)
(if (app > i n)
acc
(recur (app + i 1) (app + acc (app * i i)))))))
(fn main
(type (fn-type (params) (ret (con Unit)) (effects IO)))
(params)
(body
(app print (app sum_sq 10)))))