Record the Omega comparison-2 cohort and publish the std/temp and std/context pages
bench/results/zx-compare-omega-native-2026-11-15.json runs the comparison-2 driver on Omega from a clean clone of699eb20c(Ryzen 9 9950X, load 17.67 before / 15.96 after, I/O pressure above 70%). All 72 samples pass the oracle, backend, 1.5x IQR and M0 byte-identity checks. Warm native ZX: 0.0240 ms scalar / 0.0198 ms structured per entry, 7.8x / 20.4x faster than the engine, 6.3x / 4.5x slower than C. It is a second-machine view, not comparable with the Alpha M0 TinyCC rows; bench/zx_compare.md says so in its Omega subsection. The site pages regenerated for std/temp and std/context (module counts, modules table, usage guide sections, sitemap and the two std pages) are committed; tests/site_pages.sh passes on them at699eb20c. CHANGELOG keeps the reordered native direct-access entry, restores the dropped shared LIR optimizer entry, and notes comparison 2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
699eb20c69
commit
77a7ef0459
10 files changed
+1351
-6
No files matched your search
+2
-1
@@ -2,11 +2,12 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Interim comparison 2 (M3) is recorded on Alpha's physical host in `bench/results/zx-compare-alpha-physical-native-2026-11-15.json` and `bench/zx_compare.md`: warm native ZX runs 0.048 ms scalar and 0.063 ms structured per entry, 11× and 16× faster than the portable engine and 2.8× and 1.5× slower than the removed TinyCC tier's M0 receipt; M3 is done.
|
||||
- Native x86-64 code drops the index check of an element the shared interval analysis proves in range (fixed arrays and constant-count views such as a string constant's bytes), and reads a constant text directly, so the Sieve and Hash loops carry no pointer or index checks; Wasm drops proven view checks too. A runtime index that can leave the array or view keeps its check and traps.
|
||||
- Native code keeps records and arrays in place: aggregate values whose lifetimes never overlap share one frame slot, so an update writes only the changed member and loop-carried or branch-joined values need no copy, and on x86-64 a member read or changed through an element is done at that element's address, computed and checked once where it dominates (not at all when the shared facts prove its index); remaining copies and zeroing of 64 bytes or more run a 16-byte loop. On Omega the Records kernel drops from 1951 to 32 µs natively and from 1858 to 29 µs on the zx engine (C 8.7 µs), its image from 69,760 to 12,416 bytes, and the Sieve image from 94,336 to 8,320 bytes.
|
||||
- Native x86-64 code reaches a global or a frame allocation directly when one shared LIR pass proves the access stays inside a live root, instead of resolving its checked pointer; the machine verifier now checks every load, store, zero and byte comparison and re-derives each direct access, and Wasm takes its index proofs from the same pass. Parameters, loaded pointers and heap blocks keep their resolves, so stale aliases, resized blocks and out-of-range runtime indices still trap. A LIR `zero` is now resolved like a store instead of writing through the raw token.
|
||||
- A closed C program, linked with `--entry` and built with `--exe` or its own `main`, carries only the code it uses: each module header declares just what another generated file names, the module's `.c` keeps what only it reads, header inline copies stay only for procedures other modules call, and a module whose header would declare nothing has none. For Kryon's examples, headers shrink from 18 to 8.5 KB (window), 288 to 91 KB (hello), 319 to 102 KB (box) and 692 to 420 KB (image).
|
||||
- A closed C program's runtime headers, such as `zir_bounds.h`, `zir_slice.h`, `zir_string.h` and `zir_vec.h`, keep only the helpers its generated files call; Kryon's window headers shrink to 6.6 KB.
|
||||
- Native x86-64 code reaches a global or a frame allocation directly when one shared LIR pass proves the access stays inside a live root, instead of resolving its checked pointer; the machine verifier now checks every load, store, zero and byte comparison and re-derives each direct access, and Wasm takes its index proofs from the same pass. Parameters, loaded pointers and heap blocks keep their resolves, so stale aliases, resized blocks and out-of-range runtime indices still trap. A LIR `zero` is now resolved like a store instead of writing through the raw token.
|
||||
- Input trust tiers keep memory safety invariant while naming validation failures: bounded environment/argv, binary, file, HTTP and host-byte readers return typed outcomes; local native-cache framing reports why edited entries were refused and recompiles them; the laws inventory stable artifact and host-boundary diagnostics.
|
||||
- `#insert NAME;` at file scope splices a compile-time string constant, such as a `#string` body or `#run` output, into the module as checked source; every target sees ordinary declarations, the same from source and saved IR.
|
||||
- Modules take compile-time parameters: `#module_parameters(NAME := value, NAME: Type = value)` as a module's first declaration, and `#import "module"(NAME = value)` chooses the values, so `#if` keeps unchosen features out of C, Go, ZX, Wasm and native code. One program binds a module's parameters once; an unknown name, a value that does not fit and imports that disagree fail as `module.parameter_unknown`, `module.parameter_type` and `module.parameter_conflict`. Saved `.zir` is version 65 and keeps the bindings.
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -406,3 +406,25 @@ control. The C control (0.004596 / 0.006251 ms) is close to the M0 receipt's C
|
||||
control on the same host (0.0048 / 0.0066 ms). This closes M3's interim
|
||||
comparison item; it is not parity with TinyCC, and native code-quality work
|
||||
continues in later milestones.
|
||||
|
||||
### Omega cohort at pushed master (2026-11-15)
|
||||
|
||||
The same driver and flags also ran on Omega, in a clean clone of pushed
|
||||
`699eb20c` with its own build, writing
|
||||
`results/zx-compare-omega-native-2026-11-15.json` (SHA-256
|
||||
`24305d24c47b50312dd7a8f50bc11a16ba2cad2e59fcf45c17d7e2694b4d8806`). Omega is
|
||||
an AMD Ryzen 9 9950X (machine ID `f4fdf763de024f88b69641dcaa99e52b`,
|
||||
virtualization `none`, governor `powersave`), and it was busy: load average
|
||||
17.67 / 12.27 / 11.93 before and 15.96 / 12.42 / 12.00 after on 32 threads,
|
||||
with I/O pressure above 70% while the run queued. All 72 samples passed the
|
||||
same oracle, backend, IQR and M0 byte-identity checks as the Alpha receipt.
|
||||
Omega is not the measurement host and its numbers are not comparable with the
|
||||
Alpha M0 TinyCC rows; they show the cohorts' order on a second machine.
|
||||
|
||||
| Workload (Omega) | Portable engine | Native ZX cold | Native ZX warm | C control | AOT ELF (whole process) |
|
||||
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||
| Scalar | 0.186089 / 0.187527 | 0.334988 / 0.479878 | 0.023957 / 0.026260 | 0.003780 / 0.003813 | 0.526038 / 0.555308 |
|
||||
| Structured | 0.403903 / 0.453665 | 0.388488 / 0.455708 | 0.019796 / 0.020402 | 0.004354 / 0.004364 | 0.559788 / 0.657307 |
|
||||
|
||||
On Omega warm native ZX is 7.8× faster than the engine on scalar work and
|
||||
20.4× on structured work, and 6.3× / 4.5× slower than the C control.
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
<a href="examples.html"><span>Learn by doing</span><strong>Examples</strong><p><!-- generated:example_count -->16<!-- /generated:example_count --> complete programs with commands, each printing the same output on every target.</p><b>Browse examples →</b></a>
|
||||
<a href="language.html"><span>Language</span><strong>Syntax reference</strong><p>Modules, declarations, types, generics, control flow, compile-time forms, laws, and foreign calls.</p><b>Read the reference →</b></a>
|
||||
<a href="api.html#toolchain"><span>Toolchain</span><strong>CLI reference</strong><p>Check, build C or Go, bundle, run, format, and query the toolchain.</p><b>See commands →</b></a>
|
||||
<a href="modules.html"><span>Libraries</span><strong>Modules and packages</strong><p>Every public declaration in the <!-- generated:std_count -->106<!-- /generated:std_count --> standard modules and the ziranlang packages, generated from the source.</p><b>Browse modules →</b></a>
|
||||
<a href="modules.html"><span>Libraries</span><strong>Modules and packages</strong><p>Every public declaration in the <!-- generated:std_count -->108<!-- /generated:std_count --> standard modules and the ziranlang packages, generated from the source.</p><b>Browse modules →</b></a>
|
||||
<a href="status.html"><span>Project</span><strong>Implementation status</strong><p>See what works in the tested subset and what still needs implementation.</p><b>Check support →</b></a>
|
||||
<a href="guide/packages.html"><span>Projects</span><strong>Packages</strong><p><code>ziran.toml</code> projects, pinned Git dependencies, locks, and installing applications.</p><b>Read the guide →</b></a>
|
||||
</div></section>
|
||||
|
||||
@@ -1173,6 +1173,71 @@ backing allocation in addition to already-live old capacity, then reconcile
|
||||
against actual capacity after success. Default staging for managed elements
|
||||
and runtime object overhead require separate accounting. Ordinary Go fatal
|
||||
physical OOM remains outside recoverable allocation failures.</p>
|
||||
<h3 id="scoped-temporary-storage">Scoped temporary storage</h3>
|
||||
<p><code>std/temp</code> provides one explicit temporary byte arena for a frame, request, or
|
||||
other bounded scope. <code>TempSlice(*arena, count)</code> and <code>TempText(*arena, value)</code>
|
||||
append initialized scratch, <code>TempMark(*arena)</code> records the current boundary,
|
||||
and <code>TempReset(*arena, mark)</code> releases everything after it. Finish with
|
||||
<code>TempEnd(*arena)</code>, normally through <code>defer</code>:</p>
|
||||
<pre><code class="language-zi">#import "std/temp"
|
||||
|
||||
Frame :: () -> s32 {
|
||||
arena := TempBegin()
|
||||
defer TempEnd(*arena)
|
||||
mark := TempMark(*arena)
|
||||
label_ok := false
|
||||
{
|
||||
label := TempText(*arena, "row")
|
||||
label_ok = label == "row"
|
||||
}
|
||||
if !label_ok { return 1 }
|
||||
cells_ok := false
|
||||
{
|
||||
cells := TempSlice(*arena, 64)
|
||||
cells_ok = cells.count == 64
|
||||
}
|
||||
if !cells_ok { return 1 }
|
||||
if !TempReset(*arena, mark) { return 2 }
|
||||
return 0
|
||||
}
|
||||
</code></pre>
|
||||
<p>Slices and text are borrowed views and cannot remain live across a reset under
|
||||
the normal Vec borrow rules. Raw checked pointers are generation-bound too:
|
||||
reset-to-mark replaces and releases the old allocation, so a pointer retained
|
||||
after its view ends traps if used on the engine or native backend instead of
|
||||
silently naming reused scratch. A negative size, arithmetic overflow,
|
||||
allocation failure, null arena, or mark outside the current initialized range
|
||||
fails without changing the arena. A zero-size request returns an empty view.
|
||||
The module is ordinary checked Ziran and has the same API on C, Go, Wasm,
|
||||
portable ZX engine, and native execution.</p>
|
||||
<h3 id="explicit-scoped-context">Explicit scoped context</h3>
|
||||
<p><code>std/context</code> defines a portable <code>Context</code> record with a capture-free logger,
|
||||
scope tag, and owned <code>Temp</code> allocator. Libraries accept <code>*Context</code> explicitly;
|
||||
there is no hidden parameter or process-global current context:</p>
|
||||
<pre><code class="language-zi">#import "std/context"
|
||||
#import "std/temp"
|
||||
|
||||
Log :: (tag: string, message: string) { print("%: %\n", tag, message) }
|
||||
|
||||
Serve :: (context: *Context, request: string) -> s32 {
|
||||
defer ContextLog(context, "done")
|
||||
ContextLog(context, "start")
|
||||
return request.count
|
||||
}
|
||||
|
||||
Run :: () -> s32 {
|
||||
context := Context.{.logger = Log, .tag = "http", .allocator = TempBegin()}
|
||||
defer ContextEnd(*context)
|
||||
return Serve(*context, "GET /")
|
||||
}
|
||||
</code></pre>
|
||||
<p><code>ContextLog</code> does nothing when either the context or its logger is null.
|
||||
Platform-specific loggers remain in their platform modules; <code>std/context</code>
|
||||
itself is ordinary checked Ziran on C, Go, Wasm, portable ZX engine, and
|
||||
native execution. The allocator uses the <code>std/temp</code> API through
|
||||
<code>context.allocator</code>. Because the context owns that allocator, moving the
|
||||
record while one of its temporary views is live is rejected by the normal
|
||||
owned-value rules. <code>ContextEnd(*context)</code> releases its temporary storage.</p>
|
||||
<h3 id="building-text">Building text</h3>
|
||||
<p><code>std/format.zi</code> builds text on an owned <code>Vec(u8)</code> builder. <code>Append(*builder,
|
||||
value)</code> adds a string, integer, bool, or float, and
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ build/bin/ziran version</code></pre><a class="btn btn-primary" href="get-started
|
||||
|
||||
<section class="status-callout modules-callout" aria-labelledby="modules-title">
|
||||
<div><p class="eyebrow">Libraries</p><h2 id="modules-title">Modules and <em>packages.</em></h2></div>
|
||||
<div><p><!-- generated:module_counts -->106 standard modules and 17 packages<!-- /generated:module_counts -->, each with an API reference generated from its source, from text and JSON to image codecs.</p><a class="btn" href="modules.html">Browse all modules →</a></div>
|
||||
<div><p><!-- generated:module_counts -->108 standard modules and 17 packages<!-- /generated:module_counts -->, each with an API reference generated from its source, from text and JSON to image codecs.</p><a class="btn" href="modules.html">Browse all modules →</a></div>
|
||||
</section>
|
||||
<section class="status-callout">
|
||||
<div><p class="eyebrow"><span class="status-dot" aria-hidden="true"></span>Project status</p><h2>Working core.<br><em>Experimental edges.</em></h2></div>
|
||||
|
||||
+5
-3
@@ -1,10 +1,10 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="theme-color" content="#f7f3eb"><meta name="description" content="Every Ziran standard module and package: 106 std modules and 17 packages with API references generated from the source."><title>Ziran modules and packages</title><link rel="canonical" href="https://ziran-lang.org/modules"><link rel="icon" href="assets/logo-capybara.png" type="image/png"><link rel="stylesheet" href="styles.css"><script defer src="site.js"></script></head>
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="theme-color" content="#f7f3eb"><meta name="description" content="Every Ziran standard module and package: 108 std modules and 17 packages with API references generated from the source."><title>Ziran modules and packages</title><link rel="canonical" href="https://ziran-lang.org/modules"><link rel="icon" href="assets/logo-capybara.png" type="image/png"><link rel="stylesheet" href="styles.css"><script defer src="site.js"></script></head>
|
||||
<body><a class="skip-link" href="#main">Skip to content</a><header class="site-header"><div class="site-header-inner"><a class="brand" href="index.html"><img class="brand-icon" src="assets/logo-capybara.png" alt="" width="36" height="36"><span>Ziran</span></a><button class="menu-button" type="button" aria-expanded="false" aria-controls="primary-nav">Menu</button><nav class="header-nav" id="primary-nav" aria-label="Primary"><a href="get-started.html">Get started</a><a href="examples.html">Examples</a><a href="targets.html">Targets</a><a href="modules.html" aria-current="page">Modules</a><a href="docs.html">Docs</a><a href="status.html">Status</a><a href="https://github.com/ziranlang/ziran">GitHub ↗</a><button class="theme-toggle" type="button" aria-label="Switch color theme"></button></nav></div></header>
|
||||
<main id="main" class="article-layout"><div class="article-head"><p class="eyebrow">Reference / Modules</p><h1>Modules and <em>packages.</em></h1><p>106 standard modules and 17 packages, listed from the source on every site build. Each page shows the public declarations <code>ziran api</code> reports, with the comment written above them.</p><p class="module-meta"><span class="status-badge is-stable">Stable</span> ships in the latest release, <a href="https://github.com/ziranlang/ziran/releases/tag/v0.4.2">v0.4.2</a> (for a package: it has a tagged release). <span class="status-badge is-in-progress">In progress</span> exists only on <code>master</code> or has no release yet.</p></div>
|
||||
<main id="main" class="article-layout"><div class="article-head"><p class="eyebrow">Reference / Modules</p><h1>Modules and <em>packages.</em></h1><p>108 standard modules and 17 packages, listed from the source on every site build. Each page shows the public declarations <code>ziran api</code> reports, with the comment written above them.</p><p class="module-meta"><span class="status-badge is-stable">Stable</span> ships in the latest release, <a href="https://github.com/ziranlang/ziran/releases/tag/v0.4.2">v0.4.2</a> (for a package: it has a tagged release). <span class="status-badge is-in-progress">In progress</span> exists only on <code>master</code> or has no release yet.</p></div>
|
||||
<div class="article-grid"><aside class="page-toc"><strong>Sections</strong><a href="#std">Standard library</a><a href="#packages">Packages</a></aside><div class="article-body">
|
||||
<section id="std"><h2>Standard library</h2><p>Import a module with <code>#import "std/NAME"</code>. Modules ending in <code>_linux</code>, <code>_windows</code> or <code>_go</code> build only for that target. A module that needs a host capability runs in a portable bundle only when the program hosting the bundle binds it. 97 of 106 modules shipped in the latest release.</p><div class="table-scroll"><table class="module-table"><thead><tr><th scope="col">Module</th><th scope="col">Summary</th><th scope="col">Needs</th><th scope="col">Status</th></tr></thead><tbody>
|
||||
<section id="std"><h2>Standard library</h2><p>Import a module with <code>#import "std/NAME"</code>. Modules ending in <code>_linux</code>, <code>_windows</code> or <code>_go</code> build only for that target. A module that needs a host capability runs in a portable bundle only when the program hosting the bundle binds it. 97 of 108 modules shipped in the latest release.</p><div class="table-scroll"><table class="module-table"><thead><tr><th scope="col">Module</th><th scope="col">Summary</th><th scope="col">Needs</th><th scope="col">Status</th></tr></thead><tbody>
|
||||
<tr><th scope="row"><a href="std/atomic_go.html">atomic_go</a></th><td>Go unsigned 64-bit atomic counters.</td><td>Go target</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/binary.html">binary</a></th><td>Little-endian numbers in byte text, such as file or asset contents, read the same way on every native target and in the engine.</td><td><span class=muted>—</span></td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/binary_linux.html">binary_linux</a></th><td>Little-endian binary fields for native Linux programs.</td><td>Native Linux</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
@@ -15,6 +15,7 @@
|
||||
<tr><th scope="row"><a href="std/calendar.html">calendar</a></th><td><span class=muted>No module description yet.</span></td><td><span class=muted>—</span></td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/channel_go.html">channel_go</a></th><td>Native Go channels with runtime element types.</td><td>Go target</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/constant_time.html">constant_time</a></th><td>Constant-time equality for caller-owned byte spans.</td><td><span class=muted>—</span></td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/context.html">context</a></th><td>Explicit portable execution context.</td><td><span class=muted>—</span></td><td><span class="status-badge is-in-progress">In progress</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/context_go.html">context_go</a></th><td>Native Go contexts retain cancellation, deadlines and interface identity.</td><td>Go target</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/date_parse.html">date_parse</a></th><td>UTC calendar parsing for feeds and dated data sources, years 1 through 9999.</td><td><span class=muted>—</span></td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/date_time.html">date_time</a></th><td><span class=muted>No module description yet.</span></td><td>Host capability</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
@@ -84,6 +85,7 @@
|
||||
<tr><th scope="row"><a href="std/stdio_linux.html">stdio_linux</a></th><td>The standard streams of a native Linux program: text to standard output or standard error, and the whole of standard input.</td><td>Native Linux</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/string_range.html">string_range</a></th><td>A byte range of an immutable borrowed string.</td><td><span class=muted>—</span></td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/sync_go.html">sync_go</a></th><td>Go mutexes.</td><td>Go target</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/temp.html">temp</a></th><td>Scoped temporary byte storage.</td><td><span class=muted>—</span></td><td><span class="status-badge is-in-progress">In progress</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/text.html">text</a></th><td>ASCII-only case folding keeps the result identical across native targets and the engine.</td><td><span class=muted>—</span></td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/text_buffer.html">text_buffer</a></th><td>Bounded NUL-terminated byte buffer to borrowed text.</td><td><span class=muted>—</span></td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
<tr><th scope="row"><a href="std/text_go.html">text_go</a></th><td>Copy between Go-owned byte slices and strings, preserving every byte.</td><td>Go target</td><td><span class="status-badge is-stable">Stable</span></td></tr>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<url><loc>https://ziran-lang.org/std/calendar</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/channel_go</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/constant_time</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/context</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/context_go</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/date_parse</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/date_time</loc></url>
|
||||
@@ -122,6 +123,7 @@
|
||||
<url><loc>https://ziran-lang.org/std/stdio_linux</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/string_range</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/sync_go</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/temp</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/text</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/text_buffer</loc></url>
|
||||
<url><loc>https://ziran-lang.org/std/text_go</loc></url>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="theme-color" content="#f7f3eb"><meta name="description" content="Explicit portable execution context."><title>std/context · Ziran</title><link rel="canonical" href="https://ziran-lang.org/std/context"><link rel="icon" href="../assets/logo-capybara.png" type="image/png"><link rel="stylesheet" href="../styles.css"><script defer src="../site.js"></script></head>
|
||||
<body><a class="skip-link" href="#main">Skip to content</a><header class="site-header"><div class="site-header-inner"><a class="brand" href="../index.html"><img class="brand-icon" src="../assets/logo-capybara.png" alt="" width="36" height="36"><span>Ziran</span></a><button class="menu-button" type="button" aria-expanded="false" aria-controls="primary-nav">Menu</button><nav class="header-nav" id="primary-nav" aria-label="Primary"><a href="../get-started.html">Get started</a><a href="../examples.html">Examples</a><a href="../targets.html">Targets</a><a href="../modules.html" aria-current="page">Modules</a><a href="../docs.html">Docs</a><a href="../status.html">Status</a><a href="https://github.com/ziranlang/ziran">GitHub ↗</a><button class="theme-toggle" type="button" aria-label="Switch color theme"></button></nav></div></header>
|
||||
<main id="main" class="article-layout"><div class="article-head"><p class="eyebrow"><a href="../modules.html#std">Modules</a> / Standard library</p><h1>std/context</h1><p>Explicit portable execution context. Callers pass it like any other record; there is deliberately no hidden context parameter or global state.</p><p class="module-meta"><span class="status-badge is-in-progress">In progress</span> Added after release v0.4.2; available when building from source.</p></div>
|
||||
<div class="article-grid"><aside class="page-toc"><strong>Declarations</strong><a href="#ContextLogger">ContextLogger</a><a href="#Context">Context</a><a href="#ContextLog">ContextLog</a><a href="#ContextEnd">ContextEnd</a></aside><div class="article-body api-body">
|
||||
<section><p>Import with <code>#import "std/context"</code>.</p><div class="api-list">
|
||||
<div id="ContextLogger"><code>ContextLogger :: #type (tag: string, message: string)</code></div>
|
||||
<div id="Context"><code>Context :: struct { logger: ContextLogger; tag: string; allocator: Temp; }</code></div>
|
||||
<div id="ContextLog"><code>ContextLog :: (context: *Context, message: string)</code><p>A missing context or logger is intentionally silent, so libraries can make logging optional without installing a platform-specific default.</p></div>
|
||||
<div id="ContextEnd"><code>ContextEnd :: (context: *Context)</code></div>
|
||||
</div><p><a class="text-link" href="https://github.com/ziranlang/ziran/blob/master/std/context.zi">Source ↗</a> · <a class="text-link" href="../modules.html#std">All modules</a></p></section>
|
||||
</div></div></main>
|
||||
<footer><div class="footer-top"><a class="brand" href="../index.html"><img class="brand-icon" src="../assets/logo-capybara.png" alt="" width="36" height="36"><span>Ziran</span></a><nav aria-label="Footer"><a href="../get-started.html">Get started</a><a href="../examples.html">Examples</a><a href="../targets.html">Targets</a><a href="../modules.html">Modules</a><a href="../docs.html">Docs</a><a href="../status.html">Status</a><a href="../index.html#support">Support</a><a href="https://github.com/ziranlang/ziran">GitHub ↗</a></nav></div><div class="footer-bottom"><p>A language for useful software.</p><p>© 2026 Kryon Labs · <a href="https://waozi.xyz/">Made by Waozi</a></p></div></footer></body></html>
|
||||
@@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="theme-color" content="#f7f3eb"><meta name="description" content="Scoped temporary byte storage."><title>std/temp · Ziran</title><link rel="canonical" href="https://ziran-lang.org/std/temp"><link rel="icon" href="../assets/logo-capybara.png" type="image/png"><link rel="stylesheet" href="../styles.css"><script defer src="../site.js"></script></head>
|
||||
<body><a class="skip-link" href="#main">Skip to content</a><header class="site-header"><div class="site-header-inner"><a class="brand" href="../index.html"><img class="brand-icon" src="../assets/logo-capybara.png" alt="" width="36" height="36"><span>Ziran</span></a><button class="menu-button" type="button" aria-expanded="false" aria-controls="primary-nav">Menu</button><nav class="header-nav" id="primary-nav" aria-label="Primary"><a href="../get-started.html">Get started</a><a href="../examples.html">Examples</a><a href="../targets.html">Targets</a><a href="../modules.html" aria-current="page">Modules</a><a href="../docs.html">Docs</a><a href="../status.html">Status</a><a href="https://github.com/ziranlang/ziran">GitHub ↗</a><button class="theme-toggle" type="button" aria-label="Switch color theme"></button></nav></div></header>
|
||||
<main id="main" class="article-layout"><div class="article-head"><p class="eyebrow"><a href="../modules.html#std">Modules</a> / Standard library</p><h1>std/temp</h1><p>Scoped temporary byte storage. A mark names the initialized prefix at the instant it was taken. Releasing to a mark moves that prefix to a fresh Vec and frees the old allocation, so checked pointers into released storage are retired instead of becoming aliases of later scratch.</p><p class="module-meta"><span class="status-badge is-in-progress">In progress</span> Added after release v0.4.2; available when building from source.</p></div>
|
||||
<div class="article-grid"><aside class="page-toc"><strong>Declarations</strong><a href="#Temp">Temp</a><a href="#TempBegin">TempBegin</a><a href="#TempMark">TempMark</a><a href="#TempSlice">TempSlice</a><a href="#TempText">TempText</a><a href="#TempReset">TempReset</a><a href="#TempEnd">TempEnd</a></aside><div class="article-body api-body">
|
||||
<section><p>Import with <code>#import "std/temp"</code>.</p><div class="api-list">
|
||||
<div id="Temp"><code>Temp :: struct { bytes: Vec(u8); }</code></div>
|
||||
<div id="TempBegin"><code>TempBegin :: () -> Temp</code></div>
|
||||
<div id="TempMark"><code>TempMark :: (arena: *Temp) -> s64</code></div>
|
||||
<div id="TempSlice"><code>TempSlice :: (arena: *Temp, count: s64) -> []u8</code><p>Allocate initialized scratch at the end of the arena. An empty slice means either a zero-size request or a rejected negative/overflow/allocation request.</p></div>
|
||||
<div id="TempText"><code>TempText :: (arena: *Temp, value: string) -> string</code><p>Copy text into the arena and return a borrowed UTF-8 view.</p></div>
|
||||
<div id="TempReset"><code>TempReset :: (arena: *Temp, mark: s64) -> bool</code><p>Release everything at and after mark. Replacing the allocation deliberately retires its checked-pointer generation; retaining Vec capacity here would let a stale pointer silently name later scratch on the engine/native backends.</p></div>
|
||||
<div id="TempEnd"><code>TempEnd :: (arena: *Temp)</code></div>
|
||||
</div><p><a class="text-link" href="https://github.com/ziranlang/ziran/blob/master/std/temp.zi">Source ↗</a> · <a class="text-link" href="../modules.html#std">All modules</a></p></section>
|
||||
</div></div></main>
|
||||
<footer><div class="footer-top"><a class="brand" href="../index.html"><img class="brand-icon" src="../assets/logo-capybara.png" alt="" width="36" height="36"><span>Ziran</span></a><nav aria-label="Footer"><a href="../get-started.html">Get started</a><a href="../examples.html">Examples</a><a href="../targets.html">Targets</a><a href="../modules.html">Modules</a><a href="../docs.html">Docs</a><a href="../status.html">Status</a><a href="../index.html#support">Support</a><a href="https://github.com/ziranlang/ziran">GitHub ↗</a></nav></div><div class="footer-bottom"><p>A language for useful software.</p><p>© 2026 Kryon Labs · <a href="https://waozi.xyz/">Made by Waozi</a></p></div></footer></body></html>
|
||||
Reference in new issue
Block a user