-
Notifications
You must be signed in to change notification settings - Fork 0
params
ffredyk edited this page Jul 23, 2026
·
1 revision
Compiler Construct
params is a compiler-level construct (not a runtime-registered command) that destructures an array into named local variables. It is the primary way to unpack function arguments in SQ#.
Supports:
- Simple variable binding
- Default values for missing elements
- Type-checked binding
The compiler inlines params into _this select N expressions with optional type checks at compile time. There is no runtime params command — it is entirely resolved during compilation.
_arr = [42, "hello", true];
_arr params ["_num", "_str", "_flag"];
// _num = 42, _str = "hello", _flag = true_arr = [42];
_arr params ["_num", ["_opt", 99]];
// _num = 42, _opt = 99 (default used since _arr has < 2 elements)
_arr = [42, 77];
_arr params ["_num", ["_opt", 99]];
// _num = 42, _opt = 77 (default NOT used — value exists)_arr = [42, "player", true];
_arr params [["_num", "number"], ["_name", "string"], ["_alive", "boolean"]];
// Compiler generates type assertions — throws if types don't match_myFunc = {
params ["_a", "_b", ["_c", 0]];
_a + _b + _c
};
_result = [10, 20] call _myFunc; // 30 (_c defaults to 0)
_result = [10, 20, 5] call _myFunc; // 35[100, "player"] spawn {
params ["_hp", "_name"];
systemChat f"{_name} HP: {_hp}";
};| Syntax | Behavior |
|---|---|
"_var" |
Bind variable, no type check |
["_var", defaultValue] |
Bind with fallback |
["_var", "type"] |
Bind with type assertion |
["_var", defaultValue, "type"] |
Bind with fallback AND type check |
Compile-time only — no runtime overhead. Safe everywhere.
- Getting Started
- Language Guide
- Type System
- Control Flow
- Functions & Code
- Strings & Text
- Arrays & Collections
- Concurrency
- Promise System
- Thread Safety
- Host API & Embedding
- CLI Tool
- Bytecode Reference
- Multiplayer
- Syntax Sugar
- Optimization Guide
- Benchmarks
- count
- select
- pushBack
- append
- deleteAt
- deleteRange
- resize
- reverse
- sort
- find
- in
- forEach
- freeze
- thaw
- isFrozen
- currentScheduler
- clientOwner
- allSchedulers
- schedulerName
- schedulerExists
- schedulerBudget
- setSchedulerBudget
- fiberCount
- readyFiberCount
- waitingFiberCount
- schedulerLoad
- sendTo