-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax Sugar
ffredyk edited this page Jul 23, 2026
·
1 revision
SQ# adds optional syntax enhancements over standard SQF. All original SQF syntax still works — these are opt-in conveniences.
// SQF (required):
if (alive _unit) then { _unit setDamage 1; };
// SQ# (both OK):
if (alive _unit) { _unit setDamage 1; };
if (alive _unit) then { _unit setDamage 1; };No more "Unexpected ','" errors:
// SQF — ERROR:
_arr = [1, 2, 3,];
// SQ# — fine:
_arr = [1, 2, 3,];
params ["_a", "_b",];_arr[i] is sugar for _arr select i:
// SQF:
_first = _arr select 0;
_arr set [1, 99];
// SQ# sugar:
_first = _arr[0];
_arr[1] = 99; // assignment too!_arr # i is alternative to _arr select i:
_first = _arr # 0; // same as _arr select 0
_name = _map # "name"; // future: hashmap access// SQF — no escapes:
_msg = "Line 1" + endl + "Line 2"; // clunky
// SQ#:
_msg = "Line 1\nLine 2"; // \n works
_path = "C:\\Users\\Name"; // \\ = backslash
_quote = "He said \"Hi\""; // \" = escaped quote_path = @"C:\Users\Name\Documents"; // no escapes at all_help = """
Usage: mycommand [options]
Options:
-h, --help Show this message
""";// SQF:
_msg = format ["Player %1 has %2 HP", _name, _hp];
// SQ#:
_msg = f"Player {_name} has {_hp} HP";
// With expressions:
_msg = f"HP: {_hp}/{_maxHp} ({_hp / _maxHp * 100}%)";No need to declare or params them:
[10, 20, 30] forEach {
print f"[{_forEachIndex}] = {_x}";
};
// [0] = 10
// [1] = 20
// [2] = 30_this is also set: [_x, _forEachIndex, originalArray]
Bare names without _ are already global (SQF style). global keyword makes it explicit:
score = 100; // global (SQF style — implicit)
global HIGH_SCORE = 999; // global (explicit — same thing)private _hp: number = 100; // typed local
private _name: string = ""; // for clarity/toolingNo type coercion — == is always strict:
// SQF: "hello" == "HELLO" → true (case-insensitive — WHAT?)
// SQ#: "hello" == "HELLO" → false (strict, correct)
// SQF: "123" == 123 → maybe true, maybe error
// SQ#: "123" == 123 → false (string ≠ number)// SQF: undefined variable → "Zero Divisor" or silent fail
// SQ#: Undefined variable '_myVar'
// SQF: type mismatch → "Zero Divisor"
// SQ#: Expected Number, got String| Feature | SQF | SQ# | Required? |
|---|---|---|---|
then after if
|
Required | Optional | No |
| Trailing commas | Error | Allowed | No |
Bracket access _arr[i]
|
No | Yes | No |
Hash-select _arr # i
|
Arma 3 only | Yes | No |
String escapes \n, \t
|
No | Yes | No |
Verbatim strings @"..."
|
No | Yes | No |
Multi-line strings """..."""
|
No | Yes | No |
f-strings f"..."
|
No | Yes | No |
global keyword |
No | Yes | No |
Type annotations : type
|
No | Yes | No |
Strict ==
|
Sometimes | Always | Yes |
| Clear error messages | Rarely | Always | Yes |
All sugar is optional — standard SQF syntax continues to work. Use what you like.
- Language Guide — full syntax reference
- Strings — string handling in depth
- For SQF Scripters — differences from Arma 3 SQF
- 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