Initial Commit

This commit is contained in:
SoraKatadzuma committed 2026-11-19 04:54:17 -06:00
commit f086abcea6
789 files changed
+149185

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import std::io;
trait base {
def id(&this): i64;
def f(&this): i64 { return 1; }
def twice(&this): i64 { return this.id() * 2; }
}
trait keeps: base { def f(&this): i64; }
trait owns: base { def f(&this): i64 { return 2; } }
trait left: base { def l(&this): i64; }
trait right: base { def r(&this): i64; }
trait all: left, right {
def sum(&this): i64 { return this.twice() + this.l() + this.r(); }
}
struct z: all { var n: i64; }
def z::id(&this): i64 { return this.n; }
def z::l(&this): i64 { return 10; }
def z::r(&this): i64 { return 100; }
def main(): void {
val x := z{ n = 3 };
val k: &keeps = &x;
val o: &owns = &x;
val a: &all = &x;
val b: &base = a;
println($"{k.f()} {o.f()} {a.sum()} {b.twice()} {x.sum()}");
}