lang: rename signed integer types sN -> iN

Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.

Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).

Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.

zig build test: 426/426; examples suite: 595/595.
This commit is contained in:
agra
2026-06-12 09:31:53 +03:00
parent 515ecebea7
commit d8076b9333
1054 changed files with 6836 additions and 6839 deletions

View File

@@ -3,45 +3,45 @@
// --- Closure Basics ---
// Factory: returns a new closure each time
make_adder :: (n: s64) -> Closure(s64) -> s64 {
return closure((x: s64) -> s64 => x + n);
make_adder :: (n: i64) -> Closure(i64) -> i64 {
return closure((x: i64) -> i64 => x + n);
}
// Higher-order function: accepts any Closure(s64) -> s64
apply :: (f: Closure(s64) -> s64, x: s64) -> s64 { return f(x); }
// Higher-order function: accepts any Closure(i64) -> i64
apply :: (f: Closure(i64) -> i64, x: i64) -> i64 { return f(x); }
// Reduce: fold over a slice with a closure
reduce :: (arr: []s64, f: Closure(s64, s64) -> s64, init: s64) -> s64 {
reduce :: (arr: []i64, f: Closure(i64, i64) -> i64, init: i64) -> i64 {
acc := init;
i : s64 = 0;
i : i64 = 0;
while i < arr.len { acc = f(acc, arr[i]); i += 1; }
return acc;
}
// Auto-promoted bare function
triple :: (x: s64) -> s64 { return x * 3; }
triple :: (x: i64) -> i64 { return x * 3; }
// Struct with optional closure callback
Widget :: struct {
name: string;
on_update: ?Closure(s64) -> void;
on_update: ?Closure(i64) -> void;
}
main :: () {
// 1. Basic closure with capture
offset := 100;
add_offset := closure((x: s64) -> s64 => x + offset);
add_offset := closure((x: i64) -> i64 => x + offset);
print("basic: {}\n", add_offset(42));
// 2. Capture by value (snapshot semantics)
n := 10;
snap := closure((x: s64) -> s64 => x + n);
snap := closure((x: i64) -> i64 => x + n);
n = 999;
print("snapshot: {}\n", snap(5));
// 3. Block-body closure with control flow
clamp := closure((x: s64) -> s64 {
clamp := closure((x: i64) -> i64 {
if x < 0 { return 0; }
if x > 100 { return 100; }
return x;
@@ -65,26 +65,26 @@ main :: () {
// 7. Closure passed to higher-order function
factor := 4;
print("hof: {}\n", apply(closure((x: s64) -> s64 => x * factor), 10));
print("hof: {}\n", apply(closure((x: i64) -> i64 => x * factor), 10));
// 8. Reduce with closure
nums : []s64 = .[1, 2, 3, 4, 5];
total := reduce(nums, closure((acc: s64, x: s64) -> s64 => acc + x), 0);
nums : []i64 = .[1, 2, 3, 4, 5];
total := reduce(nums, closure((acc: i64, x: i64) -> i64 => acc + x), 0);
print("reduce: {}\n", total);
// 9. Closure captures closure
inner := closure((x: s64) -> s64 => x + 10);
outer := closure((x: s64) -> s64 => inner(x) * 2);
inner := closure((x: i64) -> i64 => x + 10);
outer := closure((x: i64) -> i64 => inner(x) * 2);
print("compose: {}\n", outer(5));
// 10. Multiple closures from same scope
base := 100;
cl_add := closure((x: s64) -> s64 => x + base);
cl_mul := closure((x: s64) -> s64 => x * base);
cl_add := closure((x: i64) -> i64 => x + base);
cl_mul := closure((x: i64) -> i64 => x * base);
print("multi: {} {}\n", cl_add(5), cl_mul(5));
// 11. Optional closures
w1 := Widget.{ name = "slider", on_update = closure((val: s64) {
w1 := Widget.{ name = "slider", on_update = closure((val: i64) {
print("widget: {} = {}\n", "slider", val);
}) };
w2 := Widget.{ name = "label", on_update = null };