Norm = Trait {.norm = (self: Self) -> Nat}

Point2D = Class {x = Int; y = Int}
Point2D|Point2D <: Norm|.
    norm self = self::x**2 + self::y**2

Point3D = Class {x = Int; y = Int; z = Int}
Point3D|Point3D <: Norm|.
    norm self = self::x**2 + self::y**2 + self::z**2

norm|T <: Norm| x: T = x.norm()

inplicit_norm x = x.norm()

p = Point2D.new {x = 3; y = 4}
print! norm(p)
assert norm(p) == 25
assert norm(Point3D.new {x = 3; y = 4; z = 5}) == 50
# assert norm(1) # this should be an error
