This commit is contained in:
agra
2026-02-28 18:03:38 +02:00
parent 2552882ce6
commit 6a920dbd2c
24 changed files with 14084 additions and 780 deletions

24
examples/test_proto.sx Normal file
View File

@@ -0,0 +1,24 @@
#import "modules/std.sx";
Point :: struct { x: s32; y: s32; }
Eq :: protocol {
eq :: (other: Self) -> bool;
}
impl Eq for Point {
eq :: (self: *Point, other: Point) -> bool {
self.x == other.x and self.y == other.y;
}
}
are_equal :: ($T: Type/Eq, a: T, b: T) -> bool {
a.eq(b);
}
main :: () {
p1 := Point.{ x = 1, y = 2 };
p2 := Point.{ x = 1, y = 2 };
p3 := Point.{ x = 3, y = 4 };
print("P6.1: {} {}\n", are_equal(p1, p2), are_equal(p1, p3));
}