import std::io; struct nothing {} struct point { var x: int; var y: f32; var tag: span; } def point::equals(&this, other: &point): bool { return this.x == other.x && this.y == other.y && this.tag == other.tag; } struct tree { var name: span; var kids: *tree; } def tree::equals(&this, other: &tree): bool { return this.name == other.name && this.kids == other.kids; } union value { var none: nothing; var whole: int; var text: span; var spot: point; } def value::equals(&this, other: &value): bool { match this { none => return other is none; whole(n) => { match other { whole(m) => return n == m; else => return false; } } text(t) => { match other { text(u) => return t == u; else => return false; } } spot(p) => { match other { spot(q) => return p == q; else => return false; } } } } def main(): void { val a := point{ x = 1, y = 0.5, tag = "a" }; var b := a; print($"{a == b} "); b.tag = "b"; val word: span = "x"; val v := value{ text = word }; val w := value{ spot = a }; val x := value{ text = word }; val three := value{ whole = 3 }; val same := value{ spot = a }; print($"{a == b} {a != b} {v == x} {v == three} {w == same} {w == v} "); var kid := tree{ name = "k", kids = null }; val t := tree{ name = "r", kids = (&mut kid) as *mut tree }; var u := t; print($"{t == u} "); u.name = "z"; print($"{t == u} {[a, b] == [a, b]} {[a] == [b]} "); match w { spot(p) => println(p == a ? "matched" : "missed"); else => println("missed"); } }