plum

#treesitter#compiler#wasm

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

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


examples/methods.plum
0e1801a 1
type Cat =
0e1801a 2
  name: Str
0e1801a 3
  age: Int
0e1801a 4
805d96d 5
  fun getAge(self) -> Int =
805d96d 6
    self.age
0e1801a 7
805d96d 8
  fun birthday(self) -> Int =
805d96d 9
    self.age + 1
0e1801a 10
0e1801a 11
type Wrapper =
0e1801a 12
  inner: Cat
0e1801a 13
  tag: Int
0e1801a 14
805d96d 15
  fun innerAge(self) -> Int =
805d96d 16
    self.inner.age
0e1801a 17
0fe3528 18
fun makeCat() -> Cat =
0e1801a 19
  Cat(name: "Whiskers", age: 3)
0e1801a 20
0fe3528 21
fun main() -> Int =
0000000 22
  c := makeCat()
0000000 23
  a := c.getAge()
0000000 24
  b := c.birthday()
0000000 25
  w := Wrapper(inner: c, tag: 1)
0e1801a 26
  a + b + w.innerAge()