Language guide · 3 of 12

Data Types & Literals

Evie is dynamically typed with a lightweight set of built-in types:

Type Description Example
number 64-bit IEEE-754 floating point 42, 3.14, -0.5
bool Boolean true, false
string UTF-8 string "hello", `hi {name}`
buffer Raw mutable byte slice buffer("hi"), fs.readFile("data.bin")
array Dynamic ordered collection [1, 2, "three"]
object Key-value map that keeps its keys in the order they were added { name: "Alice", age: 30 }
nil Represents absence of value nil
function First-class callable / closure fn(x) => x * 2
class User-defined class instance Person("Bob", 25)
task Asynchronous concurrent task go fetchData()
error Runtime or user exception error("failed")

Strings & Templates (Interpolation)

Strings are UTF-8 and operate on Unicode characters (runes) for indexing, slicing, iteration, and .len():

word := "café"
word.len()      // 4
word[3]         // "é"
word[-1]        // "é"
word[1:4]       // "afé"
Open in playground

Backtick strings support inline expression interpolation using {...}:

name := "Evie"
version := 0.1
greeting := `Welcome to {name} v{version}!`
io.println(greeting) // "Welcome to Evie v0.1!"
Open in playground

Escapes

Both kinds of string decode \n (newline), \t (tab), \r, \0, \\ (a backslash) and \". Templates also accept \`, \{ and \} for a literal backtick or brace. Any other escape is a syntax error that points at it, so a Windows path is written "C:\\Users":

io.println("one\ttwo\nthree")
io.println(`braces: \{literal\}, value: {1 + 1}, 100%`)
Open in playground

Arrays

Arrays are zero-indexed, dynamic lists supporting negative indexing, slicing, and element assignment:

fruits := ["apple", "banana", "cherry", "date"]

// Indexing
first := fruits[0]    // "apple"
last := fruits[-1]    // "date" (negative indexing from end)

// Slicing (also works on strings and buffers)
mid := fruits[1:3]    // ["banana", "cherry"]
head := fruits[:2]    // ["apple", "banana"]
tail := fruits[-2:]   // ["cherry", "date"]

// Subscript Mutation
var list := [10, 20, 30]
list[1] = 99          // list is now [10, 99, 30]
Open in playground

Objects

Objects are flexible hash maps with string keys:

user := {
    name: "Alice",
    age: 30,
    role: "admin"
}

// Field access and subscript access are interchangeable:
io.println(user.name)       // "Alice"
io.println(user["age"])     // 30

// Mutation:
var config := { debug: false }
config["debug"] = true
config["env"] = "production"
Open in playground

Edit this page on GitHub