-
Notifications
You must be signed in to change notification settings - Fork 0
call
ffredyk edited this page Jul 23, 2026
·
1 revision
Code Execution
Unary or Binary.
// Unary: no arguments
call { code }
// Binary: with arguments
<args> call { code }
<args> call <codeVariable>
Executes a code block synchronously and returns its result. The calling fiber blocks until the code completes. If used in binary form, the left-hand value becomes _this inside the code block.
call cannot suspend — sleep, await, and other suspending commands will throw an error if used inside call-executed code.
This is a compiler-level construct with a dedicated opcode. The compiler inlines the call:
- Pushes args (if binary) to the stack.
- Jumps into the code block.
- The code block's last expression is the return value.
Unlike spawn, call does not create a new fiber — it runs in the current fiber's context.
_result = call { 1 + 2; }; // returns 3
call {
systemChat "Hello";
doWork();
};_result = [10, 20] call {
params ["_a", "_b"];
_a + _b // 30
};_myFunc = compile "(_this select 0) * 2";
_result = 5 call _myFunc; // 10
_double = { _this * 2 };
_result = 7 call _double; // 14if (call { _complexCheck() }) then {
doThing();
};// call — synchronous, no sleep allowed
_result = call { 1 + 2 };
// spawn — asynchronous, sleep allowed, returns ScriptHandle
_handle = spawn { sleep 1; _result = 1 + 2; };- Cannot use
sleep,await, or any suspending command. - Runs in caller's scheduler/fiber context.
- Long-running code in
callblocks the fiber — usespawnfor heavy work.
Inherits the caller's scheduler. Safe within same scheduler. Cross-scheduler calls require spawnOn.
- spawn — async execution
- execVM — load and spawn file
- compile — compile string to code
- callUnscheduled — execute outside scheduler
- 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