72e54f4fd3
The surface-form file extension changes from .ailx to .ail. AILang's
authoring surface now uses the same .ail stem as its canonical JSON
form (.ail.json), giving the language a single coherent extension
family: .ail is the LLM-authored Form A, .ail.json is the canonical
JSON-AST Form B.
Scope (touched):
- 61 example renames examples/**/*.ailx → .ail (git mv)
- 1 rename experiments/.../rendered/ailx.md → ail.md
- 35 content-edited live-toolchain files (crates/, docs/DESIGN.md,
docs/roadmap.md, docs/PROSE_ROUNDTRIP.md, skills/, bench/reference/*.c,
experiment crates under experiments/.../{render,harness,master})
- Experiment-crate cohort rename Cohort::Ailx → Cohort::Ail,
Form::Ailx → Form::Ail, per_cohort/ailx → per_cohort/ail,
{form-only: ailx} → {form-only: ail}, ```ailx → ```ail
Out of scope (deliberately untouched, to preserve honest history):
- docs/journal-archive.md (content-frozen per CLAUDE.md)
- docs/journals/, docs/specs/, docs/plans/, bench/orchestrator-stats/
- experiments/.../runs/ (frozen LLM-output artefacts; models actually
saw .ailx — renaming would falsify the experimental record)
Verification: cargo build/test --workspace green; experiment crate
cargo test green; bench/check.py + compile_check.py + cross_lang.py
all 0-regressed; negative grep for ailx|Ailx|AILX outside the
out-of-scope paths returns zero matches.
Opens immediate follow-up: roadmap.md P2 todo `ail check`/build/run
accept .ail extension — after this rename, .ail is canonical
authoring surface but the CLI still produces a misleading JSON-parse
error on `ail check foo.ail`. That's the next iter.
58 lines
2.1 KiB
Plaintext
58 lines
2.1 KiB
Plaintext
; Iter 17a — first fixture exercising the per-fn arena (alloca for
|
|
; non-escaping allocations).
|
|
;
|
|
; `peek` builds a Box(n) and immediately matches on it, returning
|
|
; a literal Int that does not depend on the box's payload. The
|
|
; box's value is fully consumed by the local match — it never
|
|
; flows to a fn arg, never becomes a ctor field, never returns.
|
|
; Iter 17a's escape analysis flags the `(term-ctor Box MkBox n)`
|
|
; allocation as non-escaping; codegen lowers it to LLVM `alloca`
|
|
; instead of `@GC_malloc`. Boehm's heap is not touched at all by
|
|
; this fn.
|
|
;
|
|
; `count` repeats the same pattern under recursion: each call to
|
|
; `count` builds a fresh Box(_), matches it, and returns either 0
|
|
; or 1 + (count rest). Without the alloca optimisation, each
|
|
; recursive frame leaks a Box onto the GC heap until collection;
|
|
; with the optimisation, each frame's Box dies with its frame.
|
|
;
|
|
; Expected stdout (one per line):
|
|
; 42 — peek(0) returns the literal 42 from the only arm
|
|
; 42 — peek(123) ditto (the input value never reaches stdout)
|
|
; 5 — count(5)
|
|
; 0 — count(0)
|
|
|
|
(module escape_local_demo
|
|
|
|
(data Box (vars a)
|
|
(ctor MkBox a))
|
|
|
|
(fn peek
|
|
(doc "Build a Box(n), discard the payload, return 42. The Box is non-escaping.")
|
|
(type (fn-type (params (con Int)) (ret (con Int))))
|
|
(params n)
|
|
(body
|
|
(let b (term-ctor Box MkBox n)
|
|
(match b
|
|
(case (pat-ctor MkBox _) 42)))))
|
|
|
|
(fn count
|
|
(doc "Recurse n times; each call builds a temporary Box, discards its payload via _, and returns 0 if n<=0, else 1 + count(n-1).")
|
|
(type (fn-type (params (con Int)) (ret (con Int))))
|
|
(params n)
|
|
(body
|
|
(if (app <= n 0)
|
|
0
|
|
(let b (term-ctor Box MkBox n)
|
|
(match b
|
|
(case (pat-ctor MkBox _) (app + 1 (app count (app - n 1)))))))))
|
|
|
|
(fn main
|
|
(type (fn-type (params) (ret (con Unit)) (effects IO)))
|
|
(params)
|
|
(body
|
|
(seq (do io/print_int (app peek 0))
|
|
(seq (do io/print_int (app peek 123))
|
|
(seq (do io/print_int (app count 5))
|
|
(do io/print_int (app count 0))))))))
|