Files
AILang/examples/eq_demo.ail
T
Brummel 832375f2ac convention: counter-prefix file naming across docs/specs/, docs/plans/, design/contracts/, design/models/
All 176 files in the four accumulating directories now use a
zero-padded 4-digit counter prefix that reflects creation order
(`NNNN-slug.md`). The counter is assigned per directory in strict
git-log creation order; ties broken alphabetically by original name.
The old `YYYY-MM-DD-` prefix on docs/specs/ and docs/plans/ files is
dropped — the date is recoverable from git log and the counter
carries the ordering.

A file's counter is stable for the life of the file: never reassigned,
never reused, never compacted. Deleted files retire their counter;
subsequent files do not fill the gap. This is the property that lets
cross-references stay literal — refs use the full filename including
the counter (`design/contracts/0007-honesty-rule.md`) so they grep
cleanly and resolve directly without a glob step.

313 cross-references updated across .md/.rs/.toml/.c/.json files
(test pins, include_str! paths, design-INDEX entries, baseline notes,
runtime C comments, inter-contract markdown links incl. bare basename
and `../models/foo.md` forms).

CLAUDE.md gets a new "File-naming convention" section spelling out
the rule and rationale. skills/brainstorm/SKILL.md and
skills/planner/SKILL.md updated so new spec/plan creation produces
counter-prefixed names from the start.

The full test suite (cargo test --workspace) passes.
2026-05-28 13:31:31 +02:00

60 lines
2.4 KiB
Plaintext

; Equality dispatch via the prelude.Eq class for Int/Bool/Str/Unit.
; Each `(app eq x y)` call resolves to the matching primitive Eq
; instance, lowered via try_emit_primitive_instance_body in the
; codegen:
; Int → icmp eq i64
; Bool → icmp eq i1
; Str → @ail_str_eq (strcmp-based)
; Unit → constant i1 true (single-inhabitant type)
;
; Float has no Eq instance; partial-Float comparison is done via
; the explicit float_eq / float_lt / etc. fns (see
; design/contracts/0005-float-semantics.md).
;
; This fixture exercises all four supported types, both directly via
; `(app eq ...)` and indirectly via the lit-pattern desugar (which
; rewrites `(pat-lit "hi")` → `(if (eq sv "hi") body fall_k)` and
; therefore inherits the same class-dispatch path).
;
; Expected stdout (one per line):
; true ; (eq 5 5)
; false ; (eq 5 6)
; false ; (eq true false)
; true ; (eq true true)
; true ; (eq "hi" "hi")
; false ; (eq "hi" "ho")
; true ; (eq () ())
; 1 ; classify_str "hi" (lit-pattern hits 1 arm)
; 2 ; classify_str "ho" (lit-pattern hits 2 arm)
; 0 ; classify_str "??" (default arm)
;
; Driver routes through the polymorphic `print` helper (Show Bool / Show Int).
(module eq_demo
(fn classify_str
(doc "Lit-pattern over Str; exercises build_eq's class-dispatch lowering for non-Int.")
(type (fn-type (params (con Str)) (ret (con Int))))
(params s)
(body
(match s
(case (pat-lit "hi") 1)
(case (pat-lit "ho") 2)
(case _ 0))))
(fn main
(doc "Drive eq at Int/Bool/Str/Unit; then drive classify_str.")
(type (fn-type (params) (ret (con Unit)) (effects IO)))
(params)
(body
(seq (seq (app print (app eq 5 5)) (do io/print_str "\n"))
(seq (seq (app print (app eq 5 6)) (do io/print_str "\n"))
(seq (seq (app print (app eq true false)) (do io/print_str "\n"))
(seq (seq (app print (app eq true true)) (do io/print_str "\n"))
(seq (seq (app print (app eq "hi" "hi")) (do io/print_str "\n"))
(seq (seq (app print (app eq "hi" "ho")) (do io/print_str "\n"))
(seq (seq (app print (app eq (lit-unit) (lit-unit))) (do io/print_str "\n"))
(seq (seq (app print (app classify_str "hi")) (do io/print_str "\n"))
(seq (seq (app print (app classify_str "ho")) (do io/print_str "\n"))
(seq (app print (app classify_str "??")) (do io/print_str "\n"))))))))))))))