Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Development · Evolving reference

Arguments

Owns ordered native argument values without shell interpretation. Empty arguments remain real elements. No host argv lookup, whitespace splitting, quoting, Unicode normalization or filesystem operation occurs. Structural mutation/movement/destruction invalidates borrowed references and cursors. Concurrent immutable reading requires an unmoved owner; synchronize mutation. Native startup capture and generated entry forwarding are separate operations.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. 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.

Arguments

pub final class Arguments

Owns ordered native argument values without shell interpretation. Empty arguments remain real elements. No host argv lookup, whitespace splitting, quoting, Unicode normalization or filesystem operation occurs. Structural mutation/movement/destruction invalidates borrowed references and cursors. Concurrent immutable reading requires an unmoved owner; synchronize mutation. Native startup capture and generated entry forwarding are separate operations.

Example

module example.arguments;
from std.process import Arguments;
from std.text import NativeString;
fn Main() -> i32 {
    var Values = Arguments();
    if !Values.IsEmpty { return 1; }
    if Values.TryReserve(2) is .Err { Error = _ } { return 2; }
    var First = {
        // Scoped writable carriers end immediately after explicit payload transfer.
        var FirstCreation = NativeString.TryCreate("a b");
        switch FirstCreation {
            case .Ok { Value = Value: mut NativeString& } => break move(Value);
            case .Err { Error = _ } => return 3;
        }
    };
    if Values.TryPush(move(First)) is .Err { Error = _ } { return 4; }
    if Values.TryPush(NativeString()) is .Err { Error = _ } { return 5; }
    if Values.Length != 2 || Values.At(0).TryViewUtf8().Unwrap() != "a b" || !Values[1].IsEmpty { return 6; }
    let Readonly: readonly Arguments& = Values;
    var Cursor = Readonly.CreateIterator();
    switch Cursor.Next() {
        case .Some { Value = Value } => { if Value.TryViewUtf8().Unwrap() != "a b" { return 7; } }
        case .None => return 8;
    }
    var Writable = Values.CreateIterator();
    switch Writable.Next() {
        case .Some { Value = Value } => Value = NativeString();
        case .None => return 9;
    }
    if !Values.At(0).IsEmpty || !Readonly[1].IsEmpty { return 10; }
    var Moved = move(Values);
    if !Values.IsEmpty || Moved.Length != 2 { return 11; }
    return 0;
}

Arguments.init

pub init()

Starts an allocation-free empty argument list.

Arguments.init

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

Rejects implicit allocating argument copies. Source: Existing owner.

Arguments.init

pub init(Source: mut Self&&)

Transfers argument storage without parsing or allocation. Source: Owner left empty; old views must no longer be used.

Arguments.operator

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

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

Arguments.operator

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

Replaces argument ownership by explicit transfer. Source: Owner left empty except unchanged self-move. Return: No value after transferring argument backing; nested vector self-move is unchanged.

Arguments.Length

pub Length: usize;

Counts arguments, including empty values.

Arguments.IsEmpty

pub IsEmpty: bool;

Observes whether there are no arguments.

Arguments.TryReserve

pub fn TryReserve(Capacity: usize) -> Result<void, AllocationError>

Reserves argument slots without changing argument count. Capacity: Requested minimum slots. Return: Complete reservation or allocation failure; may allocate.

Arguments.TryPush

pub fn TryPush(mut Value: NativeString) -> Result<void, VectorInsertionError<NativeString>>

Appends one exact native value without splitting or quoting. Value: Owned input transferred to the list or returned in failure. Return: Ok or insertion failure owning the original value; may allocate.

Arguments.At

pub readonly fn At(Index: usize) -> readonly NativeString&

Borrows a bounds-checked immutable argument. Index: Argument index below Length; invalid indices trap. Return: Readonly reference bounded by owner/storage stability.

Arguments.At

pub fn At(Index: usize) -> mut NativeString&

Borrows a bounds-checked argument for explicit replacement/movement. Index: Argument index below Length; invalid indices trap. Return: Writable reference bounded by owner/storage stability.

Arguments.CreateIterator

pub readonly fn CreateIterator() -> SliceIterator<NativeString>

Creates allocation-free readonly ordered traversal. Return: Borrowed cursor bounded by this list's storage stability.

Arguments.CreateIterator

pub fn CreateIterator() -> WritableSliceIterator<NativeString>

Creates allocation-free writable ordered traversal. Return: Borrowed writable cursor; mutation/movement requires caller discipline.

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