Skip to main content

Syntax

Vectors

In Vapour vectors are declared with parenthesis, without the need for c prefix.

let x: int = (1, 2, 3)

Range

The : is used to define types in Vapour, so we use .. for ranges.

let x: int = 1..10

For loop

The iterator needs to be declared with let.

for(let i: int in 1..10) {
print(i)
}

Return

In Vapour return is a keywork, not a function.

func addOne(x: int): int {
return x + 1
}

Defer

Vapour adds the defer keyword which translates to on.exit, defer expects an anonymous function.

func addOne(x: int): int {
defer (): null => {
print("second!")
}

print("first")
return x + 1
}

Declaration & assignment

In Vapour assignment is always done with the = sign, <- is used for something else (see next section).

You also have to declare mutable variables with let, this avoids shooting yourself in the foot overriding variables that you should not.

let x: char = "hello"

Assign parent

In Vapour <- is used to assign to a parent variable, where one would use <<- in R.

let x: char = "hello"

if(x == "world") {
x <- "it's world!"
}

Constants

We have constants!

info

This is only checked in Vapour, we do not lock the binding in the transpiled code.

const x: char = "a constant!"

Booleans

Booleans are denoted with true and false.

const x: bool = true

Assignments

Vapour supports addition (+=) and substitution assignments (-=).

let x: int = 40
x += 2