Documentation channel: current development main at compiler checkpoint 1d7e15e. The latest tagged release is v0.0.3; pages identify APIs that are not yet released.
Syntax
Strut deliberately keeps the common path short while retaining explicit syntax where ambiguity would be expensive. Declarations use :=, assignment uses =, semicolons are mandatory, and blocks use braces.
Declarations and assignment
Use := to declare a value and infer its type. Add a type when you want an explicit contract. Existing values are changed with =.
count := 0;
name := "Strut";
int_64 large_count := 1000000;
count = 1;
Constants
Variables are mutable by default. Add const when a binding should not be reassigned.
const max_retries := 3;
const string app_name := "Strut";
Conditionals
if (score >= 90) {
print("excellent");
} else if (score >= 50) {
print("pass");
} else {
print("retry");
}
Loops
Strut supports familiar C-style loops and concise range iteration. Range iteration uses the same colon form as Nift scripting.
for (int i := 0; i < 10; i++) {
print(i);
}
for (item : items) {
print(item);
}
while (running) {
tick();
}
Functions
Return types are always explicit, including void. A void function may use a bare return;.
function add(int a, int b) -> int {
return a + b;
}
function log_ready() -> void {
print("ready");
return;
}
Comments
// A line comment.
/* A block comment
can span lines. */
Includes
Angle brackets identify Strut standard-library modules and package modules; quotes identify local project/native headers. Includes are semantic module loads, not textual C preprocessor inclusion. Core dynamic arrays use T[] with no include.
include <filesystem>;
include <sqlite>;
include "auth.h";
Switch and match
Use switch for ordinary value dispatch. Strut does not implicitly fall through between cases. match is available for exhaustive enum matching.
switch (status) {
case Status::ready: {
print("ready");
}
default: {
print("other");
}
}
match (status) {
Status::pending => { print("pending"); }
Status::ready => { print("ready"); }
Status::done => { print("done"); }
}
