plum

#treesitter#compiler#wasm

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

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


examples/functions.plum
0fe3528 1
fun addInts(a: Int, b: Int) -> Int =
0e1801a 2
  a + b
0e1801a 3
0fe3528 4
fun greet() =
0e1801a 5
  todo
0e1801a 6
0fe3528 7
fun withDefault(a: Int, step: Int = 1) -> Int =
0e1801a 8
  a + step
0e1801a 9
0fe3528 10
fun sumAll(nums: ...Int) -> Int =
0000000 11
  total := 0
0000000 12
  for v := range nums
da1c377 13
    total = total + v
da1c377 14
  total
0e1801a 15
0fe3528 16
fun wrap(value: T) -> Bool =
0e1801a 17
  True
0e1801a 18
0fe3528 19
fun pair(first: T, second: U) -> Bool =
0e1801a 20
  True
2e28ecc 21
0fe3528 22
fun useWrap() -> Bool =
2e28ecc 23
  wrap(5)
2e28ecc 24
0fe3528 25
fun usePair() -> Bool =
2e28ecc 26
  pair(1, "x")