Story
I thought about this 4 to 5 years ago, lead to pre-processing R code, an ISC submission but no funding.
I’ve tried and failed to create this multiple times over the years.
This is the first “successful” attempt.
I’m a software engineer, founder of Opifex
Opifex
Vapour is a typed superset of the R programming language.
It’s very, very new, it’s buggy, and limited.
I thought about this 4 to 5 years ago, lead to pre-processing R code, an ISC submission but no funding.
I’ve tried and failed to create this multiple times over the years.
This is the first “successful” attempt.
Vapour aims to be to R what Typescript is to Javascript.
A slightly different syntax that produces valid R code.
The syntax and type system are inspired from Go: Go’s methods == R S3.
A glimpse of vapour.
type person: object {
age: int,
name: char
}
func create(name: char): person {
return person(name = name)
}
let john: person = create("John")
The language should warn me of such problems in my code, not the users of my applications or packages.
Though the function below looks fine it really isn’t.
Can you translate that structure to any other language?
Inf
)Methods and dots in identifier.
foo <- function(x) UseMethod("foo")
foo.data <- function(x) x
foo.data.frame <- function(x) x
foo.data <- function(x) UseMethod("foo.data")
foo.data.frame <- function(x) x
What even is this?
Dynamic languages Interpreted: R, Python, Javascript, etc.
Compiled languages Compiles to machine code: C, Go, Rust, …
Preprocessors
Babel, uglify, etc.
Code to array of meaningful characters.
Based on Go’s lexer for templating language, see Rob Pike’s presentation.
switch
Build the abstract syntax tree.
Pratt parser based on Thorsten’s Writing An Interpreter In Go
Based on operator precedence: 1 + 2 * 5
Traverses the tree to implements numerous checks:
Traverses the tree to convert vapour AST to valid R code.
Install vapour, setup editor.
.vp
filevapour -infile=file.vp
Vapour: a typed superset of R