Skip to content

Runtime Values

Nubo exposes a small set of runtime values and helper functions that are always available.

Use __version__ to access the current Nubo version:

println(__version__)

Nubo automatically declares runtime variables for the currently running interpreter and file.

VariableTypeDescription
__id__intThe numeric interpreter/runtime ID.
__entry__booltrue when the current file is running as the entry interpreter, usually ID 1.
__dir__stringAbsolute directory path of the current file.
__file__stringAbsolute file path of the current file.
__concurrent__boolRuntime concurrency flag. Defaults to false.

Example:

println(__id__)
println(__entry__)
println(__dir__)
println(__file__)
println(__concurrent__)

These values are useful for loading files relative to the current script:

include __dir__ + "/config"

If the included path has no extension, Nubo automatically tries it as a .nubo file.

Use inspect() to inspect values:

import io from "@std/io"
println(inspect(io.read))

Use type() to inspect the type of a value:

let s: string|nil = "Hello"
println(s, type(s))

Use valueof() to get the underlying value representation:

import { now } from "@std/time"
println(valueof(now()))

Call a type like a function to convert a value:

import { now } from "@std/time"
println(int(now()))

You can also use conversions in collection pipelines:

let x: int = 0
bytes("hello").map(int).each(fn(n: int) {
x = x + n
})
println(x)