17 lines
511 B
Plaintext
17 lines
511 B
Plaintext
import std::io;
|
|
trait same<T> { def same(&this, other: &T): bool; }
|
|
struct pt { var x: i64; }
|
|
def pt::same(&this, other: &pt): bool { return this.x == other.x; }
|
|
type point = pt;
|
|
type spot = point;
|
|
def check<T>(a: &T, b: &T): string {
|
|
if const T is same<T> { return a.same(b) ? "same" : "differ"; }
|
|
return "unknown";
|
|
}
|
|
def main(): void {
|
|
val a: point = pt { 1 };
|
|
val b: point = pt { 1 };
|
|
val c: spot = pt { 2 };
|
|
println($"{check::<pt>(&a, &b)} {check::<point>(&a, &b)} {check::<spot>(&c, &c)}");
|
|
}
|