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.
CLS provides three declaration keywords: var, const, and let. All three support optional type annotations and type inference from the initializer expression.
var
const
let
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 declarationvar name = "CLS"; # inferred as Stringvar pi: Float = 3.14159; # explicit Float
const declares an immutable binding that cannot be reassigned. When no type annotation is given, const infers a literal type — the exact value — which is useful for union type members and type aliases.
const PI = 3.14159; # inferred as literal 3.14159const LANG = "CLS"; # inferred as literal "CLS", not Stringconst MAX: Int = 100; # explicit type annotation overrides literal inference
let is an alias for var with type inference. They behave identically at runtime.
let y = 20; # equivalent to: var y = 20;let name: String = "CLS"; # with explicit annotation
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.
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: 2var a = 10;var b = 5;print("${a + b} items"); # → 15 itemsprint("${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.
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 statementfunction 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 }.
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 implicitlyvar double = (x: int) -> x * 2;var square = (n: int) -> n * n;print(double(5)); # → 10print(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.