CLS has four built-in composite data structures — arrays, tuples, records, and structures — each optimised for a different use case. Arrays are ordered, mutable, and homogeneous. Tuples are ordered, immutable, and heterogeneous. Records are key-value maps. Structures are named flat schemas that bundle related fields under a single constructor call. All four are first-class values and can be nested, passed to functions, or stored in variables.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/elfrask/cls/llms.txt
Use this file to discover all available pages before exploring further.
Primitives (
int, float, bool, String, char) are passed by value.
Arrays, tuples, records, and structure instances share a reference in the
interpreter — assigning one variable to another does not deep-copy the
collection.Arrays
An array is an ordered, mutable sequence of values. Array literals use square brackets, and elements are separated by commas. The type annotation for an array ofT is written T[].
Index access
Arrays are zero-indexed. Usearr[index] to read or write a specific position.
Length
The built-inlen() intrinsic returns the number of elements.
Iteration
Arrays are iterable withfor each and the indexed variant:
Array methods preview
Arrays expose a set of mutation and query methods. A full reference is available on the Primitive Methods page; the most commonly used are:| Method | Description |
|---|---|
arr.push(value) | Append a value to the end |
arr.pop() | Remove and return the last element |
arr.shift() | Remove and return the first element |
arr.unshift(value) | Prepend a value to the front |
arr.indexOf(value) | First index of value, or -1 |
arr.includes(value) | true if value is present |
arr.join(sep) | Concatenate elements into a string |
arr.reverse() | Reverse the array in place |
Tuples
A tuple is an ordered, immutable sequence that can hold values of different types. Tuple literals use parentheses with comma-separated elements. The type annotation mirrors the literal form:(Int, String, Bool).
Positional access
Elements are accessed by integer index, just like arrays:Tuples are immutable — attempting to assign to an index (
t[0] = 5) will
produce a runtime error. Use an array if you need mutation.Tuples vs arrays
| Array | Tuple | |
|---|---|---|
| Literal | [1, 2, 3] | (1, "x", true) |
| Type annotation | int[] | (int, String, bool) |
| Mutability | Mutable | Immutable |
| Element types | Homogeneous | Heterogeneous |
| Primary use | Collections | Fixed-shape multi-return, coordinates |
Records
A record (also called an object or map) is an unordered collection of key-value pairs. Keys are strings; values can be any type. The type annotationRecord<String, Int> describes a record whose values are all Int.
Field access
Fields can be read using bracket notation with a string key:Common record methods
| Method | Description |
|---|---|
rec.keys() | Array of all keys |
rec.values() | Array of all values |
rec.has(key) | true if the key exists |
Type annotation
Structures
Astructure defines a named flat schema — a set of typed fields that can be instantiated with a positional constructor. Structures have no methods or inheritance; they are pure data containers, lighter than classes.
Declaration
name: Type pairs separated by commas. There are no default values in the basic form; every field must be supplied at construction time.
Construction
Call the structure name as a function, passing field values positionally in declaration order:Field access and mutation
Use dot notation to read or write individual fields:Full structure example
Structures vs classes
structure | class | |
|---|---|---|
| Methods | ❌ | ✅ |
| Inheritance | ❌ | ✅ (extends) |
me / self | ❌ | ✅ |
| Constructor syntax | Positional call | class body |
| Use case | Plain data record | Stateful object |
Use
structure when you need a lightweight named container for data. Use
class when you need encapsulated behaviour, inheritance, or me references.String interpolation
Strings in CLS support two interpolation forms: simple identifier substitution with$name and arbitrary expression substitution with ${expr}.
${...} form accepts any expression — arithmetic, function calls, member access, or nested interpolation.
Primitive Methods
Full reference for array, string, record, and tuple built-in methods.
Enums
Typed variants with identity — iteratable and switch-compatible.