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

Structs & classes

Data and lifecycle have different roles.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

Data structs

The accepted design distinguishes aggregate data structs from classes with lifecycle behavior. Struct data composition carries constrained, predictable copy, move, and default behavior.

Lifecycle classes

Classes remain native inline values; the keyword does not imply a managed heap object. Construction and destruction follow explicit lifecycle contracts, and allocating an object remains a separate operation.

Copy and move

Copy and move capabilities are type-defined and may be generated, controlled, or rejected under the lifecycle rules. A move does not imply that every class resets to a default value. The source standard-library declarations show concrete accepted ownership patterns.

Public surface

Use pub to expose declarations and members. Public APIs define the lifetime, mutation, and invalidation guarantees callers can rely on.

Readiness

Object-model details have evolved during development. Consult the selected version's API signatures and examples rather than treating older single-struct design notes as current language contracts.

Example: stored state, a property, and a readonly method

pub struct Counter {
    pub Value: i32;
    pub Limit: i32 { get; set; }

    pub readonly fn Remaining() -> i32 {
        return Limit - Value;
    }

    pub fn Increment() -> void {
        Value += 1;
    }
}

A C++ developer can recognize the data and member functions. readonly fn states the receiver's access mode, and the auto-property declares its getter and setter in one place. This declaration follows the standard library's reflected sample type and receiver syntax.

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