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 for the application entry interpreter; dependent module execution keeps it false even if its local ID is 1.
__dir__stringDirectory location for the current source.
__file__stringLocation string for the current source.
__concurrent__boolRuntime concurrency flag. Defaults to false.

Example:

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

Source locations can be virtual in embedded applications; they are not always usable host paths. Relative includes resolve through the active source loader. Assuming config.nubo exists beside the script:

include "./config.nubo"

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
let data = bytes("hello")
let codes = data.map(fn(value: byte) int {
return int(value)
})
codes.each(fn(n: int) void {
x = x + n
})
println(x)