Initial Commit
This commit is contained in:
782 files changed
+145156
No files matched your search
@@ -0,0 +1,16 @@
|
||||
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)}");
|
||||
}
|
||||
Reference in new issue
Block a user