Skip to content

Runtime

The runtime defines values that exist while an NXL program executes.

Currently:

pub enum Value {
Number(f64),
String(String),
Boolean(bool),
Null,
}

For:

let age = 23

the runtime can hold:

Value::Number(23.0)

For:

let name = "Tanmoy"

it holds:

Value::String("Tanmoy")

The environment stores variables:

Environment
name → "Tanmoy"
age → 23

It uses a hash map internally.

define("age", Value::Number(23))
get("age")

returns:

Value::Number(23)

The environment also has an assign() operation for updating existing variables.

Environments support parent scopes, allowing nested scopes to resolve values from outer scopes.