First Program¶
A Quxlang source file begins with a language declaration. Imports follow it,
then module-level declarations begin with ::name.
LANGUAGE QUXLANG EN 0.0;
IMPORT std;
::clamp FUNCTION(@value I32, @minimum I32, @maximum I32): I32
{
IF (value < minimum)
{
RETURN minimum;
}
IF (value > maximum)
{
RETURN maximum;
}
RETURN value;
}
::main FUNCTION(): I32
{
VAR volume I32 := clamp(@value 120, @minimum 0, @maximum 100);
ASSERT(volume == 100);
RETURN 0;
}
This example establishes several rules used throughout the language:
- Keywords are uppercase and user identifiers are lowercase.
::clampand::mainare declarations in the current module.@value,@minimum, and@maximumare named parameters. Their names make the roles of three same-typed arguments explicit at the call site.- Quxlang also supports explicit positional argument groups for APIs where position is meaningful; the Call arguments page introduces those after named arguments.
: I32declares the return type.VAR volume I32 := ...;declares and initializes a mutable local object.:=initializes or assigns;==compares.
The compiler operates on the enclosing source bundle. Given a bundle directory, a direct compiler invocation has this shape:
The current public invocation compiles the targets configured in
qxcbuild.yml. Its targets section defines compilation settings, while
outputs selects a target and output type for each artifact path. For example,
an output key of linux-x64/app writes ./out/output/linux-x64/app. A target
without outputs only runs its enabled static tests.
Next read Source bundles, Source files and imports, and Call arguments.