Syntax at a Glance¶
This page is the compact map of current Quxlang syntax. Each section links to a feature page with complete examples, constraints, and related concepts.
Complete source shape¶
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 result I32 := clamp(@value 120, @minimum 0, @maximum 100);
ASSERT(result == 100);
RETURN 0;
}
The first-program overview presents a complete minimal program. The language feature index lists the complete reference material.
Declaration forms¶
| Feature | Representative syntax | Reference |
|---|---|---|
| Identifier | source_value2 |
Lexical structure |
| Module declaration | ::name ... |
Names and scopes |
| Instance member | .name ... |
Structs and members |
| Mutable object | VAR value I32 := 1; |
Variables |
| Static object | STATIC value I32 := 1; |
Static objects |
| Per-thread object | ::value VAR PER_THREAD I32; |
Thread-Local Variables |
| Function | FUNCTION(@value I32): I32 |
Functions |
| Template | TEMPLATE(@T CLASS) |
Templates |
| Struct | STRUCT { ... } |
Structs |
| Base subobject | .base_part BASE base_type; |
Inheritance |
| Virtual function | .read FUNCTION() CONST VIRTUAL: I32 |
Inheritance |
| Enum | ENUM [first DEFAULT, second] |
Enums |
| Flagset | FLAGSET BITS(8) [read, write] |
Flagsets |
| Union | INLINE_UNION { .value OPTION I32; } |
Unions |
| Variant | INLINE_VARIANT [I32 DEFAULT, VOID] |
Variants |
| Interface | INTERFACE { ... } |
Interfaces |
| Owning erasure | GENERIC { ... } |
Generics |
| Build option | OPTION BOOL DEFAULT(FALSE); |
Build options |
Types and values¶
| Feature | Representative syntax | Reference |
|---|---|---|
| Integer | I32, U128, U24 |
Primitive types |
| Float | F32, F64, F16E5 |
Primitive types |
| Array | [4]I32 |
Arrays |
| Composite | :{ .value = 42; .maximum = 100; } |
Composites |
| Reference | MUT& I32, CONST& I32 |
References |
| Instance pointer | MUT->I32 |
Pointers |
| Array pointer | MUT=>>I32 |
Pointers |
| GC pointer | ~>java_object |
External types |
| Procedure | PROCEDURE(@value I32: BOOL) |
Procedure pointers |
| Typed storage | TYPED_STORAGE(point) |
Typed storage |
| Type query | TYPEOF(value), SIZEOF(I32) |
Type queries |
Calls and construction¶
configure_window(@width 1280, @height 720);
single_arg(value); // shorthand for @ARG
// Positional arguments are available when position is part of the API.
vector2(% [3, 2]);
log_message(% [message], @severity warning, % [context]);
VAR defaulted point;
VAR copied point := other;
VAR named point :(@x 3, @y 4);
// Positional construction is also available.
VAR positional point :[3, 4];
The Call Arguments, Arrays, and Constructors and Destructors references specify the corresponding language rules.
Control flow¶
Operator precedence records how expression forms group when parentheses are omitted.
| Feature | Representative syntax | Reference |
|---|---|---|
| Condition | IF (...) { ... } ELSE { ... } |
Conditional statements |
| Negative condition | UNLESS (...) { ... } |
Conditional statements |
| Loop | LOOP WHILE (...) DO { ... } |
LOOP WHILE loops |
| Clause loop | LOOP VALUE(i) FROM(0) UNTIL(4) DO { ... }; |
LOOP clauses |
| Compile-time branch | STATIC_IF(...) { ... } STATIC_ELSE { ... } |
Compile-Time Evaluation |
| Runtime-mode branch | RUNTIME NATIVE { ... } ELSE { ... } |
Runtime Selection |
| Fusion dispatch | MATCH value { TYPE I32 { ... } } |
MATCH |
| Variant specialization | VISIT value { consume(@value value); } |
VISIT |
| Labeled exit | BREAK :outer; |
Labels and GOTO |
| Typed exception handler | TRY { ... } CATCH error CONST& I32 { ... } |
Exception Handling |
| Rethrow | RETHROW; |
Exception Handling |
| Saved exception | THROW_EXCEPTION_PTR(@exception saved); |
Exception Handling |
| Scope-exit action | DEFER { ... } |
Exception Handling |
Lifetime and systems forms¶
| Feature | Representative syntax | Reference |
|---|---|---|
| Placement | PLACE AT(storage) point:[1, 2] |
Typed storage |
| Lifetime access | PUN storage AS point |
Typed storage |
| Destruction | DESTROY AT(storage) point; |
Typed storage |
| Compile-time allocation | CONSTEXPR_ALLOC#I32() |
Compile-time allocation |
| Allocation | NEW point :(@x 1, @y 2) |
NEW and DELETE |
| Deallocation | DELETE pointer; |
NEW and DELETE |
| Unchecked hierarchy downcast | pointer AS UNCHECKED_STATIC_DOWNCAST MUT->derived |
Inheritance |
| Dynamic type identity | DYNAMIC_TYPE_OF(pointer) |
Type Queries |
| Polymorphism trait | TYPE_IS_POLYMORPHIC(T) |
Type Queries |
| Checked hierarchy cast | pointer AS DYNAMIC MUT->derived |
Inheritance |
| Conditional declaration | INCLUDE_IF(OS_LINUX) |
Availability |
| Privacy | PRIVATE(MODULE) ::name ... |
Privacy |
| Native symbol | EXTERN_PROCEDURE[...] CALLABLE(...) |
External procedures |
| Assembly | ASM_PROCEDURE X64 CALLABLE(...) { ... } |
Assembly procedures |
| Atomic object | ATOMIC#I32 |
Atomic objects |
| Integer encoding | SERIALIZE_LEB128(...) |
Integer serialization |
Validation forms¶
::static_case STATIC_TEST { ASSERT(TRUE); }
::runtime_case UNIT_TEST { ASSERT(TRUE); }
::both_cases DUAL_TEST { ASSERT(TRUE); }
PANIC "unrecoverable state";
COMPILATION_ERROR "unsupported configuration";
UNIMPLEMENTED;
The Tests and Diagnostics and Explicit Failure references specify the corresponding language rules.
Composites and keyword arguments¶
Using clamp from the complete program above:
VAR options AUTO := :{ .value = 120; .minimum = 0; .maximum = 100; };
ASSERT((APPLY options TO clamp) == 100);
APPLY evaluates its composite before its target. A final @KWARGS ...
parameter captures unmatched named arguments for reflection or forwarding.
See Composites for COMPOSITE_TIE,
COMPOSITE_FORWARD, and field selection, splitting, and joining.