The 32 official plugins (str, map, json, …) are loaded from .so / .dll files in plugins/. The five built-in namespaces — blob, string, os, struct, plugin — live inside the runtime itself. They expose language-level facilities (capacity probes, formatting, CLI access, struct schema mutation, and plugin introspection) that wouldn't make sense as external libraries.
Note the namespace collision: the blob built-in is not the same as the blob plugin, and the string built-in is not the same as the str plugin. The built-ins add a handful of language-level accessors on top of the language's own blob and string types.
builtin:blob
One language-level accessor on the language's built-in blob type.
blob.Overflow
blob.Overflow($B) -> i32
Returns 1 if the last capacity-bounded write (:=) to $B truncated; 0 otherwise.
| Parameter | Type | Description |
|---|---|---|
| $B | blob | The blob to inspect. |
plugin "builtin:blob"; plugin "builtin:print"; void main() { blob $Cut[3]; blob $Src[4]; $Src[0] = 1; $Src[1] = 2; $Src[2] = 3; $Src[3] = 4; $Cut := $Src; // fits 3 of 4 bytes → truncates printf("overflow=%d\n", blob.Overflow($Cut)); // Output: overflow=1 }
builtin:string
Capacity probes and formatted construction for the language's built-in string type.
string.Overflow
string.Overflow($S) -> i32
Returns 1 if the last := assignment to $S truncated at the declared capacity; 0 otherwise.
string $T[4]; $T := "abcdefgh"; // truncates to "abcd" printf("%d\n", string.Overflow($T)); // Output: 1
string.Capacity
string.Capacity($S) -> i32
Returns the current allocated capacity of $S in bytes (which may be larger than its length if = grew it, or equal to the declared bound if only := was used).
string $S[16] = "Hello"; printf("len=%d cap=%d\n", $S.Length, string.Capacity($S)); // Output: len=5 cap=16
string.Format
string.Format($Fmt, ...) -> string
Builds a new string using printf-style formatting. Returns the formatted result as a fresh string.
| Parameter | Type | Description |
|---|---|---|
| $Fmt | string | The format string (%d, %s, %f, …). |
| … | variadic | The values to format, matching the conversions in $Fmt. |
string $F[64] = string.Format("x=%d pi=%.2f s=%s", 42, 3.14, "ok"); printf("%s\n", $F); // Output: x=42 pi=3.14 s=ok
builtin:os
Command-line arguments, well-known paths, and (in the eval family) runtime script execution.
os.ArgCount
os.ArgCount() -> i32
Number of script-level arguments (positional argv-style; the interpreter and script name are not counted).
os.Arg
os.Arg($Index) -> string
Returns the script argument at $Index (0-based). An out-of-range index returns an empty string.
plugin "builtin:os"; plugin "builtin:print"; void main() { printf("argc=%d\n", os.ArgCount()); for (i32 $I = 0; $I < os.ArgCount(); $I++) { string $A[128] = os.Arg($I); printf("[%d] %s\n", $I, $A); } }
os.ScriptPath
os.ScriptPath() -> string
Absolute path of the running .dom script file.
os.ScriptDir
os.ScriptDir() -> string
Directory containing the running script. Useful for resolving paths relative to the script itself rather than to the working directory.
os.ExePath
os.ExePath() -> string
Absolute path of the DominScript interpreter binary.
os.HasFlag
os.HasFlag($Name) -> bool
Returns true if any script argument exactly matches $Name (typically a --flag style string).
if (os.HasFlag("--verbose") == 1) { printf("verbose mode on\n"); }
os.GetOption
os.GetOption($Name) -> string
Returns the value following $Name in the script arguments, e.g. with --port 8080 on the command line, os.GetOption("--port") returns "8080". Returns an empty string if $Name is not present.
os.GetOptionOrDefault
os.GetOptionOrDefault($Name, $Default) -> string
Like GetOption, but returns $Default when the option is missing.
string $Port[16] = os.GetOptionOrDefault("--port", "8080"); printf("port=%s\n", $Port); // Output (no --port given): port=8080
Eval family — runtime script execution
The os.Eval family lets you compile and run a string of DominScript code at runtime, in the caller's function scope. os.ValidateScript performs the same static checks without executing.
os.ValidateScript
os.ValidateScript($Code) -> i32
Lexes, parses, and binds $Code as if it were going to run in the current scope. Returns 1 on success, 0 on failure. Not a runtime-success guarantee — only a static check. On failure, the os.LastValidation* getters carry the details.
os.Eval
os.Eval($Code) -> i32
Runs $Code as a continuation of the caller's function scope. New locals declared in the fragment are added to the caller's call frame and are released with it. The fragment sees the caller's variables, struct bindings, and plugin imports.
Not allowed in an eval fragment: plugin "..." directives, top-level function / struct / enum declarations. These are rejected as DISALLOWED validation errors.
i32 $Counter = 10; string $Code[64] = "$Counter = $Counter + 5;"; if (os.ValidateScript($Code) == 1) { os.Eval($Code); } printf("%d\n", $Counter); // Output: 15
os.LastValidationCategory / Line / Column / Offset / Error / Warnings
os.LastValidationCategory() -> i32 // 0..6 (see table) os.LastValidationLine() -> i32 // 1-based, 0 if no location os.LastValidationColumn() -> i32 // 1-based, 0 if no location os.LastValidationOffset() -> i32 // byte offset, -1 if none os.LastValidationError() -> string // human-readable message os.LastValidationWarnings() -> string // binder warnings (rare)
Thread-local getters that describe the most recent ValidateScript / Eval failure on this thread.
| Value | Meaning |
|---|---|
| 0 | NONE — everything is fine |
| 1 | LEXER — invalid character, unterminated string, bad escape |
| 2 | PARSER — syntax error (missing ;, wrong structure) |
| 3 | BINDER — semantic error (type, scope, unknown variable) |
| 4 | PARAM — wrong argument to a plugin/built-in call |
| 5 | DISALLOWED — construct not permitted in an eval fragment |
| 6 | INTERNAL — internal error (OOM, unexpected state) |
builtin:struct
The struct keyword for schema definition, plus four helpers for mutating struct schemas at runtime — either globally or per blob instance.
struct (keyword)
struct Pont { i32 x; i32 y; } struct Fejlec packet { u8 jelzo; i32 hossz; }
Top-level schema declaration. With the packet qualifier the layout follows the wire-packed convention (no padding between members); without it the natural alignment is used. Each declaration registers a globally addressable schema name.
AddStructMember
AddStructMember($SchemaName, $MemberName, $TypeStr, $InsertIdx)
Adds a member to a global struct schema at the given insertion index (0 = front, MemberCount = end). All future bindings of that schema see the new member; existing blobs are unaffected unless re-bound.
| Parameter | Type | Description |
|---|---|---|
| $SchemaName | string | Name of the schema to mutate (e.g. "Pont"). |
| $MemberName | string | New member name. |
| $TypeStr | string | Type literal (e.g. "i32", "string[64]", "blob[8]"). |
| $InsertIdx | i32 | Position. 0 inserts at the front, MemberCount appends. |
struct Pont { i32 x; i32 y; } AddStructMember("Pont", "z", "i32", 2); // append as third member
DelStructMember
DelStructMember($SchemaName, $MemberName)
Removes a member from a global schema. Existing blobs are unaffected unless re-bound.
AddBlobMember
AddBlobMember(ref $Blob, $MemberName, $TypeStr, $InsertIdx, $Migrate)Adds a member to this blob's per-instance schema (does not touch the global schema). $Migrate selects whether the existing blob bytes are physically reorganised:
$Migrate = 1— the blob is rewritten so existing members keep their values at their new offsets.$Migrate = 0— the blob bytes stay in place; only the schema view changes. Faster, but reads of moved members will see whatever bytes happen to lie there.
blob $B[8]; $B assign Pont; AddBlobMember(ref $B, "z", "i32", 2, 1); // migrate bytes
DelBlobMember
DelBlobMember(ref $Blob, $MemberName)Removes a member from a blob's per-instance schema. The blob bytes are not reclaimed; the schema view just no longer covers that field.
builtin:plugin
Introspection — list loaded plugins, count their functions, and look their names up by index.
plugin.Count
plugin.Count() -> i32
Number of plugins currently loaded (built-ins included).
plugin.Path
plugin.Path($Index) -> string
Returns the load path of the plugin at $Index. For built-ins this is the "builtin:<name>" identifier; for external plugins it is the path you passed to the plugin directive.
plugin.IsBuiltin
plugin.IsBuiltin($Index) -> bool
true if the plugin at $Index is one of the runtime built-ins; false if it was loaded from a shared library.
plugin.FunctionCount
plugin.FunctionCount($Index) -> i32
Number of functions exported by the plugin at $Index.
plugin.FunctionFullName
plugin.FunctionFullName($PluginIdx, $FunctionIdx) -> string
The fully qualified name of one of a plugin's functions (e.g. "str.Find"). Useful for diagnostic listings and dispatch tables built at runtime.
plugin "builtin:plugin"; plugin "builtin:print"; plugin "../plugins/str/StrPlugin"; void main() { i32 $N = plugin.Count(); for (i32 $I = 0; $I < $N; $I++) { string $P[128] = plugin.Path($I); printf("%d %s (%d fn)\n", $I, $P, plugin.FunctionCount($I)); } }