so... jai :D

This commit is contained in:
agra
2026-02-04 01:34:30 +02:00
commit 55fc5790e4
60 changed files with 15876 additions and 0 deletions

43
examples/08-types.sx Normal file
View File

@@ -0,0 +1,43 @@
#import "modules/std.sx";
SPECIAL_VALUE :u8: 42;
resolve :: (x: u8) -> s32 {
return 12 + x;
}
Foo :: struct {
a : u2; // this will have 0 as default
b : u8 = SPECIAL_VALUE;
c : u8 = ---; // default for c is undefined
d : u8 = #run xx resolve(5); // converts s32 to u8
}
main :: () {
a : Foo; // default value of 0
print("a 0 : {}\n", a);
a.a = 1;
// a.c is still undefined at this point
a.c = 8;
print("a 1 : {}\n", a);
large: f64 = 5989.5;
b : Foo = ---; // undefined
b.a = 1;
b.c = xx large; // converts f64 to u8
// expect stdout : "b: Foo{a:1, b: 42, c: 7, d: 12}"
print("b: {}", b);
print("\n");
f := Pack.{1,0,3,5,9,100,3.5};
print("{}\n", f);
}
Pack :: struct {
a: u1;
b: u2;
c: u8;
d: u32;
f: u64;
v: s32;
x: f32;
}