vapourlang / vapour

Typed superset of R
http://vapour.run
Apache License 2.0
162 stars 2 forks source link

Enums #70

Open ElianHugh opened 2 days ago

ElianHugh commented 2 days ago

Hello!

One thing that was I always missed in R was enums -- factors don't count!

Theoretically they could transpile to match arg or something similar?

E.g.

enum foo = ("a", "b")

func bar(x: foo): char {
  return(x)
}

Could transpile to

foo <- c("a", "b")

bar <- function(x = foo) {
  match.arg(x)
  return(x)
}