plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


examples/methods.plum
type Cat =
  name: Str
  age: Int

  fun getAge(self) -> Int =
    self.age

  fun birthday(self) -> Int =
    self.age + 1

type Wrapper =
  inner: Cat
  tag: Int

  fun innerAge(self) -> Int =
    self.inner.age

fun makeCat() -> Cat =
  Cat(name: "Whiskers", age: 3)

fun main() -> Int =
  c := makeCat()
  a := c.getAge()
  b := c.birthday()
  w := Wrapper(inner: c, tag: 1)
  a + b + w.innerAge()