Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
0.2.0 Preview 1 · Frozen documentation

ProgramInputs

Owns an explicit argument/environment payload for startup and embedding. Construction transfers existing owners without allocation, host lookup or I/O. No ambient argv/environment alias remains. Ordinary mutations use the nested owners' checked APIs. Moving/destroying the payload invalidates borrowed owner references and every nested view/cursor. Concurrent reads require stable ownership; externally synchronize edits. Native capture/entry forwarding is separate from constructing this portable payload.

Sn is under heavy development. Reference extracted from this release’s bundled standard library. Public API examples are not an exhaustive compatibility test. Read the matching release guide for tested workflows and limitations. Read the status →

Module std.process

import std.process;

Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.

ProgramInputs

pub final class ProgramInputs

Owns an explicit argument/environment payload for startup and embedding. Construction transfers existing owners without allocation, host lookup or I/O. No ambient argv/environment alias remains. Ordinary mutations use the nested owners' checked APIs. Moving/destroying the payload invalidates borrowed owner references and every nested view/cursor. Concurrent reads require stable ownership; externally synchronize edits. Native capture/entry forwarding is separate from constructing this portable payload.

Example

module example.program_inputs;
from std.process import Arguments, Environment, ProgramInputs;
from std.text import NativeString;
fn Main() -> i32 {
    var Values = Arguments();
    var Text = {
        // Scoped writable carriers end immediately after explicit payload transfer.
        var TextCreation = NativeString.TryCreate("--shipping");
        switch TextCreation {
            case .Ok { Value = Value: mut NativeString& } => break move(Value);
            case .Err { Error = _ } => return 1;
        }
    };
    if Values.TryPush(move(Text)) is .Err { Error = _ } { return 2; }
    var Variables = Environment();
    var Inputs = ProgramInputs(move(Values), move(Variables));
    if !Values.IsEmpty || !Variables.IsEmpty { return 3; }
    {
        let Readonly: readonly ProgramInputs& = Inputs;
        if Readonly.Arguments().Length != 1 || !Readonly.Environment().IsEmpty { return 4; }
        if Readonly.Arguments()[0].TryViewUtf8().Unwrap() != "--shipping" { return 5; }
    }
    if Inputs.Arguments().TryPush(NativeString()) is .Err { Error = _ } { return 6; }
    if Inputs.Environment().TryReserve(2) is .Err { Error = _ } { return 7; }
    var Moved = move(Inputs);
    if !Inputs.Arguments().IsEmpty || Moved.Arguments().Length != 2 { return 8; }
    var Replacement = ProgramInputs(Arguments(), Environment());
    Replacement = move(Moved);
    if !Moved.Arguments().IsEmpty || Replacement.Arguments().Length != 2 { return 9; }
    return 0;
}

ProgramInputs.init

pub init(mut Arguments: Arguments, mut Environment: Environment)

Adopts explicit owners without allocating or capturing host state. Arguments: Owned ordered values transferred into this payload. Environment: Owned explicit entries transferred into this payload.

ProgramInputs.init

pub init(Source: readonly Self&) = delete;

Rejects implicit allocating payload copies. Source: Existing owner.

ProgramInputs.init

pub init(Source: mut Self&&)

Transfers both nested owners without allocation or I/O. Source: Payload left with empty arguments/environment.

ProgramInputs.operator

pub fn operator =(Source: readonly Self&) -> void = delete;

Rejects implicit allocating assignment. Source: Existing owner. Return: No runtime result; this assignment is deleted and cannot be invoked.

ProgramInputs.operator

pub fn operator =(Source: mut Self&&) -> void

Replaces both nested owners by explicit transfer. Source: Payload left empty except unchanged self-move. Return: No value after replacing the argument and environment owners.

ProgramInputs.Arguments

pub readonly fn Arguments() -> readonly Arguments&

Borrows readonly argument ownership without copying native values. Return: Reference expiring on payload movement/destruction.

ProgramInputs.Arguments

pub fn Arguments() -> mut Arguments&

Borrows writable argument ownership for explicit edits. Return: Reference expiring on payload movement/destruction; inner views also follow argument storage stability.

ProgramInputs.Environment

pub readonly fn Environment() -> readonly Environment&

Borrows readonly environment ownership without searching/copying. Return: Reference expiring on payload movement/destruction.

ProgramInputs.Environment

pub fn Environment() -> mut Environment&

Borrows writable environment ownership for checked explicit edits. Return: Reference expiring on payload movement/destruction; keys remain controlled by the Environment mutation API.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library