nybl-sys
The standard host for the Nybl programming language — a NyblHost implementation that wires Nybl up to the normal OS-backed conveniences (filesystem, stdio, environment, time) plus the bundled Nybl stdlib.
If you're writing a command-line tool or a desktop / server app that runs Nybl scripts, StdHost is the default you want. Custom embeddings (sandboxed, wasm, no_std) should write their own NyblHost impl.
What StdHost provides
Import resolution
use std.math/std.json/std.collections/ … → resolved vianybl-lang's bundled stdlib (thenybl-stdfeature, forwarded by default)use my_module/my.nested.module→ resolved from the filesystem beneath the host's module root (the current working directory by default; the CLI sets it to the script's parent)
Host functions (available to Nybl code as fn_name(...))
readline()— read a line from stdinread_file(path)/write_file(path, contents)/append_file(path, contents)/file_exists(path)— filesystem basicsenv(var_name)— read an environment variableunix_time()/unix_time_ms()— current time, seconds / milliseconds since epochprintis provided bynybl-langitself;StdHostroutes output to stdout
Host functions always receive value arguments. Explicit ref arguments are
supported only by user-defined Nybl functions; write a Nybl wrapper when a
script needs to update one of its own variables transactionally.
Quick start
[]
= "0.5"
= "0.5"
use ;
use StdHost;
Prefer the faster bytecode runtime? Drop in nybl-vm — StdHost works unchanged:
run?;
When not to use nybl-sys
- Sandboxed embeddings that need to block filesystem / env access — write a bare
NyblHostimpl and skip this crate entirely. - WASM / no_std builds —
nybl-sysdepends onstdand is an OS-oriented host. On WASI its clock functions use the platform clock. Onwasm32-unknown-unknown,unix_time()andunix_time_ms()return a Nybl runtime error instead of panicking because that target has no system clock. Browser and other freestanding wasm embeddings should usenybl-lang(optionally withnybl-vm) directly and provide time through a customNyblHost. - Anywhere you want a tighter custom host surface —
NyblHost::callis the only thing you need to implement; your host can expose exactly the functions your app wants Nybl to reach.
Related crates
nybl-lang— the language core +NyblHosttrait- The Nybl stdlib this crate routes
use std.*to lives insidenybl-langbehind thenybl-stdfeature (forwarded by default fromnybl-sys). nybl-vm— faster bytecode runtime, drop-in with the sameStdHostnybl-cli— thenyblbinary built on top ofnybl-sys
License
Dual-licensed under MIT or Apache 2.0, at your option.