protocols

This commit is contained in:
agra
2026-02-24 19:46:17 +02:00
parent 9dba8eef5b
commit 06d10541da
5 changed files with 431 additions and 1 deletions

View File

@@ -2834,5 +2834,19 @@ END;
print("P2.6: {} {}\n", acc.total, dbl.val);
}
// P2.7: xx on inline struct literal (no intermediate variable)
{
use_adder :: (a: Adder) -> s32 { a.add(10); a.value(); }
result := use_adder(xx Accumulator.{ total = 5 });
print("P2.7: {}\n", result);
}
// P3.3: xx on inline struct literal with vtable protocol
{
use_counter :: (c: Counter) -> s32 { c.inc(); c.inc(); c.get(); }
result := use_counter(xx SimpleCounter.{ val = 100 });
print("P3.3: {}\n", result);
}
print("=== DONE ===\n");
}