Files
sx/examples/0037-basic-trailing-commas.sx
agra 59f0aa7716 std: restructure — std/ modules, namespace tail, std/xml.sx
allocators/fs/process/socket/log/trace/test move under modules/std/
(allocators.sx becomes std/mem.sx; the Allocator protocol moves into
the std.sx prelude, impls stay in mem.sx). New std/xml.sx holds
xml_escape as xml.escape. std.sx gains the carried namespace tail —
flat-importing std.sx now also provides mem./xml./log. — with the
remaining modules (fs/process/socket/json/cli/hash/test) deferred from
the tail until the global last-wins maps are fully own-wins (pulling
them into every closure collides bare names corpus-wide; they stay
direct imports: modules/std/fs.sx etc.). log.sx's internal emit
renamed log_emit (it clobbered consumer fns named emit program-wide).
bundle.sx uses xml.escape via the carried alias. Consumer import paths
swept mechanically; .ir snapshots recaptured for the larger std
closure. m3te + game build unchanged.
2026-06-11 06:10:59 +03:00

37 lines
999 B
Plaintext

#import "modules/std.sx";
#import "modules/math/math.sx";
#import "modules/compiler.sx";
#import "modules/std/test.sx";
pkg :: #import "modules/testpkg";
add :: (a: s32, b: s32) -> s32 { a + b }
main :: () {
// ── Trailing commas ──────────────────────────────────────────
print("=== Trailing Commas ===\n");
{
// Struct literal with trailing comma
Vec4 :: struct { x: f64; y: f64; z: f64; w: f64; }
v := Vec4.{
x = 1.0,
y = 2.0,
z = 3.0,
w = 4.0,
};
assert(v.x == 1.0);
assert(v.w == 4.0);
// Function call with trailing comma
add :: (a: s64, b: s64) -> s64 { return a + b; }
r := add(10, 20,);
assert(r == 30);
// Array literal with trailing comma
arr := s64.[1, 2, 3,];
assert(arr[2] == 3);
print("trailing commas ok\n");
}
}