erg 0.6.53

The Erg programming language
Documentation
unittest = pyimport "unittest"

Test! = Inherit unittest.TestCase!
_ = Test!

# forward reference
C = Class { .x = D }
C|<: Eq|.
    `==` self, other = self.x == other.x
C.
    foo self, x = self.x.foo(x)
D = Class { .y = Int }
D.
    new y = Self { .y; }
    @staticmethod
    foo x = x + 1
    bar self, x := 1 = self.y + x
    one = Self.new 1
D|<: Eq|.
    `==` self, other = self.y == other.y

d = D.new 1
assert d.foo(1) == 2
assert d.bar(x:=2) == 3

c = C.new { .x = D.new(1) }
assert c.x.y == 1

Vec = Class [Int; _]
Vec.
    sum self =
        sum(self::base)

v = Vec.new [1, 2, 3]
assert v.sum() == 6