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

Arrays & slices

Contiguous storage and borrowed views.

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

Fixed arrays

T[N] is inline contiguous storage for exactly N live elements. N is a compile-time usize. An array does not itself allocate on the heap.

Slices

T[] and readonly T[] provide read-only non-owning views. mut T[] grants writable element access. Slices carry data and length; they neither own the elements nor retain their backing owner.

Projections

Arrays and slices expose .Length and .Data. Obtaining the raw data pointer does not make its dereference safe or extend any lifetime.

Indexing

Base[Index] checks that the index is below the length in every profile and fatal-traps on failure. The index has the expected type usize. Writable access yields a writable element place; read-only access does not.

Invalidation

Returning a slice backed by a local array is invalid. Container growth, moves, or destruction may invalidate a view. The owner and operation contracts determine when a borrowed view remains usable.

Example: borrow a view of fixed storage

var Samples: i32[4] = [10, 20, 30, 40];
let View: readonly i32[] = Samples;
let First: i32 = View[0];

Samples owns the four elements. View borrows them as a slice; it is not another four-element array. Keep the backing storage alive while the view is used. These are local declarations, using the fixed-array and readonly-slice forms.

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