Standard Library

VCore

Time, sleep, platform, input, string building, process information, and realtime telemetry.

vcore is the environment and utility module. Import it with use native vcore;.

Time and sleep

FunctionResultNotes
vcore.now()StringLocal time formatted YYYY-MM-DD HH:MM:SS.
vcore.now_ns()Int64Monotonic nanoseconds. Origin is arbitrary; use differences for durations.
vcore.sleep(ms)Int64Blocks for ms milliseconds; returns 1.

now_ns is the timing substrate for vynec bench and the library benchmarks.

Environment

FunctionResultNotes
vcore.platform()String"Windows x64", "Linux", "Mac OSX", ...
vcore.input(prompt?)String / nullReads one line from stdin, optionally printing a prompt.
vcore.versionStringCompiler/runtime version.
vcore.engineStringEngine identifier.
vcore.buildStringBuild descriptor.
vcore.processor_countInt64Logical processor count.
vcore.pidInt64Process id.
vcore.memory_usageInt64Process memory usage in bytes (platform-dependent).
 vyne snippetvyne
use native vcore; out("platform: " + vcore.platform()); out("now: " + vcore.now()); t0 :: Int64 := vcore.now_ns(); heavy_work(); out("ms: " + string(float64(vcore.now_ns() - t0) / 1_000_000.0));

Parsing helpers

FunctionResultNotes
vcore.parse_array(text)ArrayParses a nested bracket/number representation such as "[1, 2, [3, 4]]".
vcore.hex_to_int64(text)Int64Parses a hexadecimal string, with or without the 0x prefix.
vcore.chr(code)StringOne-byte string from a code point masked to 0..255.
 vyne snippetvyne
arr := vcore.parse_array("[1, 2, [3, 4]]"); mask := vcore.hex_to_int64("0xFF2D809A"); letter := vcore.chr(65); # "A"

chr is intended for assembling multi-byte UTF-8 sequences from computed bytes.

String builder

The string builder avoids repeated reallocation on append-heavy output.

FunctionResultNotes
vcore.sb_create()Int64Creates a builder and returns its handle.
vcore.sb_append(handle, value)nullAppends any value, stringified.
vcore.sb_append_char(handle, code)nullAppends one byte without allocating a one-character string.
vcore.sb_build(handle)StringReturns an independent copy of the contents.
vcore.sb_reset(handle)nullRewinds size to 0, keeps capacity.
 vyne snippetvyne
sb :: Int64 := vcore.sb_create(); through i :: 0..9 -> loop { vcore.sb_append(sb, i); vcore.sb_append_char(sb, 44); # ',' }; out(vcore.sb_build(sb));

sb_append_char is the substrate for byte-oriented parsers such as vcsv.

Realtime telemetry

@realtime<ms> regions maintain a small stats table. Read it with:

FunctionResult
vcore.realtime_worst_ms()Worst observed elapsed milliseconds across all realtime regions.
vcore.realtime_overruns()Total overrun count.
vcore.realtime_reset()Clear the aggregate counters.
vcore.realtime_worst_ms_named(name)Worst observed time for one named region.
vcore.realtime_overruns_named(name)Overrun count for one named region.
 vyne snippetvyne
@realtime<5> region control_tick { controller.step(reading); }; out("worst: " + string(vcore.realtime_worst_ms())); out("overruns: " + string(vcore.realtime_overruns()));

The AVR runtime exposes the same five calls through arduino.realtime_*.

AVR note

On the Arduino target only time and sleep are meaningful. now, now_ns, and sleep are registered; filesystem, process, and input APIs are desktop-only.

See also