Runtime Values
Nubo exposes a small set of runtime values and helper functions that are always available.
Version
Section titled “Version”Use __version__ to access the current Nubo version:
println(__version__)Runtime Variables
Section titled “Runtime Variables”Nubo automatically declares runtime variables for the currently running interpreter and file.
| Variable | Type | Description |
|---|---|---|
__id__ | int | The numeric interpreter/runtime ID. |
__entry__ | bool | true for the application entry interpreter; dependent module execution keeps it false even if its local ID is 1. |
__dir__ | string | Directory location for the current source. |
__file__ | string | Location string for the current source. |
__concurrent__ | bool | Runtime 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.
Inspect
Section titled “Inspect”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))Value Of
Section titled “Value Of”Use valueof() to get the underlying value representation:
import { now } from "@std/time"
println(valueof(now()))Conversions
Section titled “Conversions”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)