holey-bytes/hblang/examples/structs.hb

27 lines
321 B
Plaintext
Raw Normal View History

2024-05-12 05:16:40 -05:00
Ty := struct {
a: int,
b: int,
2024-05-12 05:16:40 -05:00
}
2024-05-12 13:10:50 -05:00
Ty2 := struct {
ty: Ty,
c: int,
}
2024-05-12 05:16:40 -05:00
main := fn(): int {
2024-05-13 02:38:33 -05:00
finst := Ty2.{ ty: Ty.{ a: 4, b: 1 }, c: 3 };
inst := odher_pass(finst);
2024-05-12 13:10:50 -05:00
if inst.c == 3 {
2024-05-12 15:40:28 -05:00
return pass(&inst.ty);
2024-05-12 13:10:50 -05:00
}
return 0;
}
2024-05-12 15:40:28 -05:00
pass := fn(t: *Ty): int {
2024-05-12 13:10:50 -05:00
return t.a - t.b;
2024-05-12 05:16:40 -05:00
}
2024-05-13 02:38:33 -05:00
odher_pass := fn(t: Ty2): Ty2 {
return t;
}