Skip to main content

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.

CLS is a statically-typed language with a clean, expression-oriented syntax. Every source file is a sequence of declarations and statements. Statements are terminated by semicolons (;), and block-level declarations — such as classes, interfaces, enums, and modules — close with };. Identifiers are case-sensitive and must begin with a letter or underscore; they may contain letters, digits, and underscores. The file extension for CLS source files is .clsx.

Comments

CLS uses # for single-line comments. There are no multi-line comment delimiters — use multiple # lines for longer annotations.
# This is a comment
var x = 1;   # inline comment at the end of a line

Variables

CLS provides three declaration keywords: var, const, and let. All three support optional type annotations and type inference from the initializer expression.
var declares a mutable variable. Without an annotation, the type is inferred as the base type of the initializer (e.g., String, not a string literal type).
var x: int = 42;          # typed declaration
var name = "CLS";         # inferred as String
var pi: Float = 3.14159;  # explicit Float
const infers a literal type when no annotation is provided, while var and let always infer the base type. This distinction matters for union types: const k = "red" gives k the type "red", whereas var k = "red" gives it the type String.

Primitive Types

CLS has eight built-in primitive types. Both the long and short forms are accepted as type annotations.
TypeAliasesDescription
Intint, i32, i64, Integer64-bit signed integer
Floatfloat, f32, f6464-bit floating-point number
StringstrUTF-8 character string
Boolbool, BooleanBoolean value (true or false)
Charchar, CharacterA single Unicode character
AnyanyDynamic type — assignable to and from everything
NullThe null value; type of null
VoidvoidNo value; used as the return type of procedures

Operators

Arithmetic

OperatorDescriptionExample
+Additiona + b
-Subtractiona - b
*Multiplicationa * b
/Divisiona / b
%Modulo10 % 31
**Exponentiation2 ** 8256

Comparison

OperatorDescription
==Strict equality
!=Inequality
<Less than
<=Less than or equal
>Greater than
>=Greater than or equal

Logical

OperatorDescription
&&Logical AND (short-circuits: false && expr skips expr)
||Logical OR (short-circuits: true || expr skips expr)
!Logical NOT
andKeyword form of AND, used in for each x and idx in (...)

Assignment

OperatorDescription
=Assignment
+=Add and assign
-=Subtract and assign
*=Multiply and assign
/=Divide and assign
++Postfix increment
--Postfix decrement

Special Operators

OperatorDescriptionExample
::Namespace accessmath::abs(-1)
->Return type annotation / arrow functionfunction f() -> Int
|Type union"red" | "green" | "blue"
inMembership testitem in collection
isInstance-of checkx is MyClass

String Interpolation

Double-quoted and backtick strings support interpolation using $ for simple variable references and ${...} for arbitrary expressions.
var name = "CLS";
var version = 2;

print("Hello, $name!");           # → Hello, CLS!
print("Version: $version");       # → Version: 2

var a = 10;
var b = 5;
print("${a + b} items");          # → 15 items
print("${a > b} is the result");  # → true is the result
Single-quoted strings ('text') do not interpolate. Use double quotes or backticks when you need to embed variable values.

Literals

KindExamplesNotes
Integer42, -1, 064-bit signed
Float3.14, -0.5, 1.064-bit double
String"hello", 'world', `template`Double/backtick interpolate
Booleantrue, false
Char'a'Single character in single quotes
NullnullAbsence of a value

Collection Literals

CLS has three collection literal forms, each with its own type and mutability rules.
# Homogeneous, mutable — type inferred from the first element
var numbers: Int[] = [1, 2, 3, 4, 5];
var names = ["Alice", "Bob", "Charlie"];  # String[]

numbers[0];          # → 1
len(numbers);        # → 5

Statement Termination

Every statement in CLS ends with a semicolon (;). Block-level declarations — class, interface, alias, enum, structure, module, namespace, and function bodies — close their braces with };.
var x = 10;                  # simple statement

function add(a: int, b: int) -> int {
    return a + b;            # statement inside a block
};                           # block declaration closes with };

class Counter {
    var count: int = 0;
    function increment() {
        me.count++;
    };
};
Omitting the semicolon after a closing } is a syntax error for declarations. The rule is: statements end in ;, and blocks that are declarations also require ; after the closing }.

Reserved Keywords

The following identifiers are reserved by CLS and cannot be used as variable or function names:
CategoryKeywords
Variablesvar, const, let
Functionsfunction, void, method, export
Control flowif, elif, then, else, while, loop, for, each, in, switch, case, default, break, continue, return, with
Error handlingtry, catch, finally
Classes & typesclass, structure, interface, module, namespace, alias, enum, extends, is, super, readonly, me
Importsimport, from, as, include
Asyncasync, await, sync
Modifierspublic, private, protected, static, global
Otherand, macro, config, true, false

Arrow Functions

Arrow functions are anonymous function expressions that capture their lexical environment (closures). They can be written in expression form or block form.
# Single-expression body — the expression value is returned implicitly
var double = (x: int) -> x * 2;
var square = (n: int) -> n * n;

print(double(5));     # → 10
print(square(6));     # → 36
Arrow functions assigned to var have their type inferred as a function type, e.g. (Int) -> Int. You can declare an explicit function-type alias: alias DoubleFunc = (Int) -> Int.

Build docs developers (and LLMs) love